← 返回首页
[3.12] gh-80527: Change support.requires_legacy_unicode_capi() (GH-108438) by miss-islington · Pull Request #108446 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

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

Provide feedback

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

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (5) All 1 file type selected Viewed files
Conversations
Failed to load comments. Retry
Loading
Jump to
Jump to file
Failed to load files. Retry
Loading
Diff view
Unified
Split
Hide whitespace
Apply and reload
Show whitespace
Diff view
Unified
Split
Hide whitespace
Apply and reload
15 changes: 8 additions & 7 deletions Lib/test/support/__init__.py
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
from .testresult import get_test_runner


try:
from _testcapi import unicode_legacy_string
except ImportError:
unicode_legacy_string = None

__all__ = [
# globals
"PIPE_MAX_SIZE", "verbose", "max_memuse", "use_resources", "failfast",
Expand Down Expand Up @@ -507,8 +502,14 @@ def has_no_debug_ranges():
def requires_debug_ranges(reason='requires co_positions / debug_ranges'):
return unittest.skipIf(has_no_debug_ranges(), reason)

requires_legacy_unicode_capi = unittest.skipUnless(unicode_legacy_string,
'requires legacy Unicode C API')
def requires_legacy_unicode_capi():
try:
from _testcapi import unicode_legacy_string
except ImportError:
unicode_legacy_string = None

return unittest.skipUnless(unicode_legacy_string,
'requires legacy Unicode C API')

# Is not actually used in tests, but is kept for compatibility.
is_jython = sys.platform.startswith('java')
Expand Down
8 changes: 4 additions & 4 deletions Lib/test/test_capi/test_getargs.py
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ def test_et_hash(self):
buf = bytearray()
self.assertRaises(ValueError, getargs_et_hash, 'abc\xe9', 'latin1', buf)

@support.requires_legacy_unicode_capi
@support.requires_legacy_unicode_capi()
def test_u(self):
from _testcapi import getargs_u
with self.assertWarns(DeprecationWarning):
Expand All @@ -1037,7 +1037,7 @@ def test_u(self):
with self.assertWarns(DeprecationWarning):
self.assertRaises(TypeError, getargs_u, None)

@support.requires_legacy_unicode_capi
@support.requires_legacy_unicode_capi()
def test_u_hash(self):
from _testcapi import getargs_u_hash
with self.assertWarns(DeprecationWarning):
Expand All @@ -1053,7 +1053,7 @@ def test_u_hash(self):
with self.assertWarns(DeprecationWarning):
self.assertRaises(TypeError, getargs_u_hash, None)

@support.requires_legacy_unicode_capi
@support.requires_legacy_unicode_capi()
def test_Z(self):
from _testcapi import getargs_Z
with self.assertWarns(DeprecationWarning):
Expand All @@ -1069,7 +1069,7 @@ def test_Z(self):
with self.assertWarns(DeprecationWarning):
self.assertIsNone(getargs_Z(None))

@support.requires_legacy_unicode_capi
@support.requires_legacy_unicode_capi()
def test_Z_hash(self):
from _testcapi import getargs_Z_hash
with self.assertWarns(DeprecationWarning):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_csv.py
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def test_writerows_errors(self):
self.assertRaises(OSError, writer.writerows, BadIterable())

@support.cpython_only
@support.requires_legacy_unicode_capi
@support.requires_legacy_unicode_capi()
@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_writerows_legacy_strings(self):
import _testcapi
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_decimal.py
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def test_explicit_from_string(self):
self.assertRaises(InvalidOperation, Decimal, "1_2_\u00003")

@cpython_only
@requires_legacy_unicode_capi
@requires_legacy_unicode_capi()
@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_from_legacy_strings(self):
import _testcapi
Expand Down Expand Up @@ -2919,7 +2919,7 @@ def test_none_args(self):
Overflow])

@cpython_only
@requires_legacy_unicode_capi
@requires_legacy_unicode_capi()
@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_from_legacy_strings(self):
import _testcapi
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_unicode.py
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ def test_isidentifier(self):
self.assertFalse("0".isidentifier())

@support.cpython_only
@support.requires_legacy_unicode_capi
@support.requires_legacy_unicode_capi()
@unittest.skipIf(_testcapi is None, 'need _testcapi module')
def test_isidentifier_legacy(self):
u = '𝖀𝖓𝖎𝖈𝖔𝖉𝖊'
Expand Down Expand Up @@ -2491,7 +2491,7 @@ def test_getnewargs(self):
self.assertEqual(len(args), 1)

@support.cpython_only
@support.requires_legacy_unicode_capi
@support.requires_legacy_unicode_capi()
@unittest.skipIf(_testcapi is None, 'need _testcapi module')
def test_resize(self):
for length in range(1, 100, 7):
Expand Down
Toggle all file notes Toggle all file annotations

Footer

© 2026 GitHub, Inc.