Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.4k
gh-133036: Deprecate codecs.open#133038
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.
Conversation
vstinner left a comment
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.
LGTM
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
vstinner commentedApr 27, 2025
Aha, 2 tests failed on the CI: test_multibytecodec and test_sax. |
malemburg left a comment
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.
Thanks for the PR. You are still missing a few places which need to be updated:
- Lib/test/test_multibytecodec.py uses codecs.open()
- Lib/test/test_sax.py uses codecs.open()
- Lib/_pyio.py references codecs.open() for non-text encodings
- Modules/_io/textio.c mentions codecs.open() as an alternative command
There may be more places. I have only searched for "codecs.open".
When you're done making the requested changes, leave the comment: |
vstinner commentedApr 28, 2025
Tests fail on Windows: |
vstinner commentedApr 28, 2025
To fix test_codecs on Windows, you can apply this change for example: diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.pyindex a35de8ad87c..28039ae6cdd 100644--- a/Lib/test/test_codecs.py+++ b/Lib/test/test_codecs.py@@ -35,13 +35,13 @@ def check(input, expect): # On small versions of Windows like Windows IoT or Windows Nano Server not all codepages are present def is_code_page_present(cp):- from ctypes import POINTER, WINFUNCTYPE, WinDLL+ from ctypes import POINTER, WINFUNCTYPE, WinDLL, Structure from ctypes.wintypes import BOOL, BYTE, WCHAR, UINT, DWORD MAX_LEADBYTES = 12 # 5 ranges, 2 bytes ea., 0 term. MAX_DEFAULTCHAR = 2 # single or double byte MAX_PATH = 260- class CPINFOEXW(ctypes.Structure):+ class CPINFOEXW(Structure): _fields_ = [("MaxCharSize", UINT), ("DefaultChar", BYTE*MAX_DEFAULTCHAR), ("LeadByte", BYTE*MAX_LEADBYTES), |
hugovk commentedApr 28, 2025
Please could you also list it inhttps://github.com/python/cpython/blob/main/Doc/deprecations/pending-removal-in-future.rst ? |
methane commentedApr 29, 2025
I have made the requested changes; please review again |
Thanks for making the requested changes! @vstinner,@malemburg: please review the changes made to this pull request. |
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
vstinner left a comment
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.
LGTM
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Victor Stinner <vstinner@python.org>
4e294f6 intopython:mainUh oh!
There was an error while loading.Please reload this page.
vstinner commentedApr 30, 2025
Nicely done, thank you. |
malemburg commentedApr 30, 2025
Looks good now. Thanks. |
Uh oh!
There was an error while loading.Please reload this page.
codecs.open()#133036📚 Documentation preview 📚:https://cpython-previews--133038.org.readthedocs.build/