-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-101144: Allow open and read_text encoding to be positional. #101145
gh-101144: Allow open and read_text encoding to be positional. #101145
Conversation
As was the behavior in 3.9 and earlier. The fix for python#87817 introduced an API regression in 3.10.0b1.
This preserves the intent of python#87817 while restoring the ability to pass `encoding` as a positional argument.
(internally at work the bug this fixes comes from b/266007820) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will need to be ported to zipp as well.
If only the affected user had been using the backport for forward-compatibility, they would have discovered this issue much earlier. On further consideration, I guess it's not a matter of forward compatibility (as zipp will often be ahead of some slightly stale Python version). The issue really lies in that the code is only tested on one major version.
This change is mostly fine, but I have some concerns I'd like to see investigated/addressed before proceeding.
When you're done making the requested changes, leave the comment: |
I have made the requested changes; please review again. |
Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
Sorry, @gpshead, I could not cleanly backport this to |
Sorry @gpshead, I had trouble checking out the |
…ional. (pythonGH-101145) The zipfile.Path open() and read_text() encoding parameter can be supplied as a positional argument without causing a TypeError again. 3.10.0b1 included a regression that made it keyword only. Documentation update included as users writing code to be compatible with a wide range of versions will need to consider this for some time.. (cherry picked from commit 5927013) Co-authored-by: Gregory P. Smith <[email protected]>
#101179 applies it to 3.11 and will be proposed as a 3.10 backport, though we may just update the 3.10 docs and not fix it in that branch. |
…onal. (python/cpython#101145) The zipfile.Path open() and read_text() encoding parameter can be supplied as a positional argument without causing a TypeError again. 3.10.0b1 included a regression that made it keyword only. Documentation update included as users writing code to be compatible with a wide range of versions will need to consider this for some time.
…onal. (python/cpython#101145) The zipfile.Path open() and read_text() encoding parameter can be supplied as a positional argument without causing a TypeError again. 3.10.0b1 included a regression that made it keyword only. Documentation update included as users writing code to be compatible with a wide range of versions will need to consider this for some time.
…n 3.12.0 Gregory P. Smith (1): python/cpython#101144: Allow open and read_text encoding to be positional. (python/cpython#101145) Jason R. Coombs (13): Honor ResourceWarnings. Fixes jaraco/skeleton#73. tox 4 requires a boolean value, so use '1' to FORCE_COLOR. Fixes jaraco/skeleton#74. Remove unnecessary shebang and encoding header in docs conf. Prevent Python 3.12 from blocking checks. Build docs in CI, including sphinx-lint. Put tidelift docs dependency in its own section to limit merge conflicts. Update badge for 2023 Update changelog. Ref python/cpython#101144. Invoke test_encoding_warnings in-process, but skip when warn_default_encoding is not set. Re-use alpharep fixture for the file. Provide 'sys.flags.warn_default_encoding' for the tests to skip prior to 3.10. Due to mypy, it's not possible to patch the value, so just be lenient in access. Prefer simple asserts Replace trailing comment with a comment on a separate line.
This was the behavior in 3.9 and earlier. The fix for #87817 introduced an API regression in 3.10.0b1.
zipfile.Path.read_text
&.open
methods with a positionalencoding
arg causes a TypeError #101144