gh-133036: Deprecate codecs.open#133038
Conversation
|
Aha, 2 tests failed on the CI: test_multibytecodec and test_sax. |
malemburg
left a comment
There was a problem hiding this comment.
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>
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/