bpo-43651: Fix EncodingWarning in zipfile (GH-25650)

This commit is contained in:
Inada Naoki 2021-04-27 15:45:31 +09:00 committed by GitHub
parent 5987b8c463
commit caae717c29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 28 deletions

View file

@ -2334,6 +2334,8 @@ class Path:
if args or kwargs:
raise ValueError("encoding args invalid for binary operation")
return stream
else:
kwargs["encoding"] = io.text_encoding(kwargs.get("encoding"))
return io.TextIOWrapper(stream, *args, **kwargs)
@property
@ -2345,6 +2347,7 @@ class Path:
return pathlib.Path(self.root.filename).joinpath(self.at)
def read_text(self, *args, **kwargs):
kwargs["encoding"] = io.text_encoding(kwargs.get("encoding"))
with self.open('r', *args, **kwargs) as strm:
return strm.read()