Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
methane merged 9 commits intopython:mainfrommethane:deprecate-codecs-open
Apr 30, 2025

Conversation

methane
Copy link
Member

@methanemethane commentedApr 27, 2025
edited by github-actionsbot
Loading

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

@vstinner
Copy link
Member

Aha, 2 tests failed on the CI: test_multibytecodec and test_sax.

Copy link
Member

@malemburgmalemburg left a 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".

@bedevere-app
Copy link

When you're done making the requested changes, leave the comment:I have made the requested changes; please review again.

@vstinner
Copy link
Member

Tests fail on Windows:

ERROR: test_code_page_decode_flags (test.test_codecs.CodePageTest.test_code_page_decode_flags)----------------------------------------------------------------------Traceback (most recent call last):  File "D:\a\cpython\cpython\Lib\test\test_codecs.py", line 3466, in test_code_page_decode_flags    if is_code_page_present(cp):       ~~~~~~~~~~~~~~~~~~~~^^^^  File "D:\a\cpython\cpython\Lib\test\test_codecs.py", line 44, in is_code_page_present    class CPINFOEXW(ctypes.Structure):                    ^^^^^^NameError: name 'ctypes' is not defined. Did you mean: 'type'? Or did you forget to import 'ctypes'?

@vstinner
Copy link
Member

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
Copy link
Member

Please could you also list it inhttps://github.com/python/cpython/blob/main/Doc/deprecations/pending-removal-in-future.rst ?

vstinner reacted with thumbs up emoji

@methane
Copy link
MemberAuthor

I have made the requested changes; please review again

@bedevere-app
Copy link

Thanks for making the requested changes!

@vstinner,@malemburg: please review the changes made to this pull request.

methaneand others added2 commitsApril 29, 2025 17:23
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Copy link
Member

@vstinnervstinner left a 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>
@hugovkhugovk changed the titlegh-133036: deprecate codecs.opengh-133036: Deprecate codecs.openApr 29, 2025
@methanemethane merged commit4e294f6 intopython:mainApr 30, 2025
42 checks passed
@methanemethane deleted the deprecate-codecs-open branchApril 30, 2025 01:11
@vstinner
Copy link
Member

Nicely done, thank you.

@malemburg
Copy link
Member

Thanks for making the requested changes!

@vstinner,@malemburg: please review the changes made to this pull request.

Looks good now. Thanks.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@AA-TurnerAA-TurnerAA-Turner left review comments

@StanFromIrelandStanFromIrelandStanFromIreland left review comments

@vstinnervstinnervstinner approved these changes

@hugovkhugovkhugovk approved these changes

@malemburgmalemburgAwaiting requested review from malemburg

Assignees
No one assigned
Labels
stdlibPython modules in the Lib dir
Projects
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@methane@vstinner@hugovk@malemburg@AA-Turner@StanFromIreland

[8]ページ先頭

©2009-2025 Movatter.jp