You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a regression from 3.9 behavior seen in Python 3.10.
zipfile.Path.read_text passes *args and **kwargs to it's own open() method, but in 3.10+ is also blindly sets kwargs["encodings"] to a value. So code that was previously passing an encoding as a positional argument now sees:
File "/<stdlib>/zipfile.py", line 2362, in read_text
with self.open('r', *args, **kwargs) as strm:
File "/<stdlib>/zipfile.py", line 2350, in open
return io.TextIOWrapper(stream, *args, **kwargs)
TypeError: Failed to construct dataset imagenet2012: argument for TextIOWrapper() given by name ('encoding') and position (2)
def read_text(self, *args, **kwargs):
kwargs["encoding"] = io.text_encoding(kwargs.get("encoding")) # <-- new in 3.10, source of bug
with self.open('r', *args, **kwargs) as strm:
return strm.read()
As this is a regression, we should avoid setting that value in kwargs when "encodings" not in kwargs to match 3.9 and earlier behavior.
This is a regression from 3.9 behavior seen in Python 3.10.
zipfile.Path.read_text passes *args and **kwargs to it's own
open()method, but in 3.10+ is also blindly setskwargs["encodings"]to a value. So code that was previously passing an encoding as a positional argument now sees:3.10's Lib/zipfile.py (and main's Lib/zipfile/_path.py) contain:
As this is a regression, we should avoid setting that value in kwargs when
"encodings" not in kwargsto match 3.9 and earlier behavior.TODO list:
Linked PRs