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

Commit0eb6d87

Browse files
[3.12]gh-80527: Change support.requires_legacy_unicode_capi() (GH-108438) (#108446)
gh-80527: Change support.requires_legacy_unicode_capi() (GH-108438)The decorator now requires to be called with parenthesis: @support.requires_legacy_unicode_capi()instead of: @support.requires_legacy_unicode_capiThe implementation now only imports _testcapi when the decorator iscalled, so "import test.support" no longer imports the _testcapiextension.(cherry picked from commit995f4c4)Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent2262190 commit0eb6d87

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

‎Lib/test/support/__init__.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
from .testresultimportget_test_runner
2222

2323

24-
try:
25-
from_testcapiimportunicode_legacy_string
26-
exceptImportError:
27-
unicode_legacy_string=None
28-
2924
__all__= [
3025
# globals
3126
"PIPE_MAX_SIZE","verbose","max_memuse","use_resources","failfast",
@@ -507,8 +502,14 @@ def has_no_debug_ranges():
507502
defrequires_debug_ranges(reason='requires co_positions / debug_ranges'):
508503
returnunittest.skipIf(has_no_debug_ranges(),reason)
509504

510-
requires_legacy_unicode_capi=unittest.skipUnless(unicode_legacy_string,
511-
'requires legacy Unicode C API')
505+
defrequires_legacy_unicode_capi():
506+
try:
507+
from_testcapiimportunicode_legacy_string
508+
exceptImportError:
509+
unicode_legacy_string=None
510+
511+
returnunittest.skipUnless(unicode_legacy_string,
512+
'requires legacy Unicode C API')
512513

513514
# Is not actually used in tests, but is kept for compatibility.
514515
is_jython=sys.platform.startswith('java')

‎Lib/test/test_capi/test_getargs.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ def test_et_hash(self):
10211021
buf=bytearray()
10221022
self.assertRaises(ValueError,getargs_et_hash,'abc\xe9','latin1',buf)
10231023

1024-
@support.requires_legacy_unicode_capi
1024+
@support.requires_legacy_unicode_capi()
10251025
deftest_u(self):
10261026
from_testcapiimportgetargs_u
10271027
withself.assertWarns(DeprecationWarning):
@@ -1037,7 +1037,7 @@ def test_u(self):
10371037
withself.assertWarns(DeprecationWarning):
10381038
self.assertRaises(TypeError,getargs_u,None)
10391039

1040-
@support.requires_legacy_unicode_capi
1040+
@support.requires_legacy_unicode_capi()
10411041
deftest_u_hash(self):
10421042
from_testcapiimportgetargs_u_hash
10431043
withself.assertWarns(DeprecationWarning):
@@ -1053,7 +1053,7 @@ def test_u_hash(self):
10531053
withself.assertWarns(DeprecationWarning):
10541054
self.assertRaises(TypeError,getargs_u_hash,None)
10551055

1056-
@support.requires_legacy_unicode_capi
1056+
@support.requires_legacy_unicode_capi()
10571057
deftest_Z(self):
10581058
from_testcapiimportgetargs_Z
10591059
withself.assertWarns(DeprecationWarning):
@@ -1069,7 +1069,7 @@ def test_Z(self):
10691069
withself.assertWarns(DeprecationWarning):
10701070
self.assertIsNone(getargs_Z(None))
10711071

1072-
@support.requires_legacy_unicode_capi
1072+
@support.requires_legacy_unicode_capi()
10731073
deftest_Z_hash(self):
10741074
from_testcapiimportgetargs_Z_hash
10751075
withself.assertWarns(DeprecationWarning):

‎Lib/test/test_csv.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def test_writerows_errors(self):
282282
self.assertRaises(OSError,writer.writerows,BadIterable())
283283

284284
@support.cpython_only
285-
@support.requires_legacy_unicode_capi
285+
@support.requires_legacy_unicode_capi()
286286
@warnings_helper.ignore_warnings(category=DeprecationWarning)
287287
deftest_writerows_legacy_strings(self):
288288
import_testcapi

‎Lib/test/test_decimal.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ def test_explicit_from_string(self):
587587
self.assertRaises(InvalidOperation,Decimal,"1_2_\u00003")
588588

589589
@cpython_only
590-
@requires_legacy_unicode_capi
590+
@requires_legacy_unicode_capi()
591591
@warnings_helper.ignore_warnings(category=DeprecationWarning)
592592
deftest_from_legacy_strings(self):
593593
import_testcapi
@@ -2919,7 +2919,7 @@ def test_none_args(self):
29192919
Overflow])
29202920

29212921
@cpython_only
2922-
@requires_legacy_unicode_capi
2922+
@requires_legacy_unicode_capi()
29232923
@warnings_helper.ignore_warnings(category=DeprecationWarning)
29242924
deftest_from_legacy_strings(self):
29252925
import_testcapi

‎Lib/test/test_unicode.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ def test_isidentifier(self):
814814
self.assertFalse("0".isidentifier())
815815

816816
@support.cpython_only
817-
@support.requires_legacy_unicode_capi
817+
@support.requires_legacy_unicode_capi()
818818
@unittest.skipIf(_testcapiisNone,'need _testcapi module')
819819
deftest_isidentifier_legacy(self):
820820
u='𝖀𝖓𝖎𝖈𝖔𝖉𝖊'
@@ -2491,7 +2491,7 @@ def test_getnewargs(self):
24912491
self.assertEqual(len(args),1)
24922492

24932493
@support.cpython_only
2494-
@support.requires_legacy_unicode_capi
2494+
@support.requires_legacy_unicode_capi()
24952495
@unittest.skipIf(_testcapiisNone,'need _testcapi module')
24962496
deftest_resize(self):
24972497
forlengthinrange(1,100,7):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp