bpo-43651: Fix EncodingWarning in zipfile (GH-25650)
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 0eed4ce..d99c0d7 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -2334,6 +2334,8 @@ def open(self, mode='r', *args, pwd=None, **kwargs):
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 @@ def filename(self):
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()