mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-43651: Fix EncodingWarning in zipfile (GH-25650)
This commit is contained in:
parent
5987b8c463
commit
caae717c29
2 changed files with 31 additions and 28 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue