-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-133036: Deprecate codecs.open #133038
Conversation
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
Aha, 2 tests failed on the CI: test_multibytecodec and test_sax. |
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: |
Tests fail on Windows:
|
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.py
index 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),
|
Please could you also list it in https://github.com/python/cpython/blob/main/Doc/deprecations/pending-removal-in-future.rst ? |
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. |
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
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
Co-authored-by: Victor Stinner <vstinner@python.org>
Nicely done, thank you. |
Looks good now. Thanks. |
codecs.open()
#133036📚 Documentation preview 📚: https://cpython-previews--133038.org.readthedocs.build/