Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.2k
gh-101144: Allow open and read_text encoding to be positional.#101145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
a4f19a4
b495172
e304094
9caec6c
b4248b1
32b252b
d1228b5
8ee213e
25dd5bd
e9b373f
a12243b
35abedb
88ecd56
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
As was the behavior in 3.9 and earlier. The fix for#87817 introduced an APIregression in 3.10.0b1.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -258,7 +258,8 @@ def open(self, mode='r', *args, pwd=None, **kwargs): | ||
raise ValueError("encoding args invalid for binary operation") | ||
return stream | ||
else: | ||
if "encoding" in kwargs: | ||
kwargs["encoding"] = io.text_encoding(kwargs["encoding"]) | ||
gpshead marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
return io.TextIOWrapper(stream, *args, **kwargs) | ||
@property | ||
@@ -282,7 +283,8 @@ def filename(self): | ||
return pathlib.Path(self.root.filename).joinpath(self.at) | ||
def read_text(self, *args, **kwargs): | ||
gpshead marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if "encoding" in kwargs: | ||
kwargs["encoding"] = io.text_encoding(kwargs["encoding"]) | ||
with self.open('r', *args, **kwargs) as strm: | ||
gpshead marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
return strm.read() | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
:func:`zipfile.Path.open` and :func:`zipfile.Path.read_text` accept | ||
``encoding`` as a positional argument. This was the behavior in Python 3.9 and | ||
earlier. 3.10 introduced an unintended regression where supplying it as a | ||
positional argument would lead to a :exc:`TypeError`. |