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

Commit2ca52bf

Browse files
authored
Merge pull request#5702 from arihant2math/struct-313
Update struct to 3.13.3 and update parts of test.support
2 parentsa917da3 +662d3a1 commit2ca52bf

File tree

5 files changed

+180
-168
lines changed

5 files changed

+180
-168
lines changed

‎Lib/test/support/__init__.py

Lines changed: 95 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@
7474
#
7575
# The timeout should be long enough for connect(), recv() and send() methods
7676
# of socket.socket.
77-
LOOPBACK_TIMEOUT=5.0
78-
ifsys.platform=='win32'and' 32 bit (ARM)'insys.version:
79-
# bpo-37553: test_socket.SendfileUsingSendTest is taking longer than 2
80-
# seconds on Windows ARM32 buildbot
81-
LOOPBACK_TIMEOUT=10
82-
elifsys.platform=='vxworks':
83-
LOOPBACK_TIMEOUT=10
77+
LOOPBACK_TIMEOUT=10.0
8478

8579
# Timeout in seconds for network requests going to the internet. The timeout is
8680
# short enough to prevent a test to wait for too long if the internet request
@@ -113,7 +107,6 @@
113107
STDLIB_DIR=os.path.dirname(TEST_HOME_DIR)
114108
REPO_ROOT=os.path.dirname(STDLIB_DIR)
115109

116-
117110
classError(Exception):
118111
"""Base class for regression test exceptions."""
119112

@@ -259,22 +252,16 @@ class USEROBJECTFLAGS(ctypes.Structure):
259252
# process not running under the same user id as the current console
260253
# user. To avoid that, raise an exception if the window manager
261254
# connection is not available.
262-
fromctypesimportcdll,c_int,pointer,Structure
263-
fromctypes.utilimportfind_library
264-
265-
app_services=cdll.LoadLibrary(find_library("ApplicationServices"))
266-
267-
ifapp_services.CGMainDisplayID()==0:
268-
reason="gui tests cannot run without OS X window manager"
255+
importsubprocess
256+
try:
257+
rc=subprocess.run(["launchctl","managername"],
258+
capture_output=True,check=True)
259+
managername=rc.stdout.decode("utf-8").strip()
260+
exceptsubprocess.CalledProcessError:
261+
reason="unable to detect macOS launchd job manager"
269262
else:
270-
classProcessSerialNumber(Structure):
271-
_fields_= [("highLongOfPSN",c_int),
272-
("lowLongOfPSN",c_int)]
273-
psn=ProcessSerialNumber()
274-
psn_p=pointer(psn)
275-
if ( (app_services.GetCurrentProcess(psn_p)<0)or
276-
(app_services.SetFrontProcess(psn_p)<0) ):
277-
reason="cannot run without OS X gui process"
263+
ifmanagername!="Aqua":
264+
reason=f"{managername=} -- can only run in a macOS GUI session"
278265

279266
# check on every platform whether tkinter can actually do anything
280267
ifnotreason:
@@ -391,11 +378,12 @@ def wrapper(*args, **kw):
391378

392379
defskip_if_buildbot(reason=None):
393380
"""Decorator raising SkipTest if running on a buildbot."""
381+
importgetpass
394382
ifnotreason:
395383
reason='not suitable for buildbots'
396384
try:
397385
isbuildbot=getpass.getuser().lower()=='buildbot'
398-
except (KeyError,EnvironmentError)aserr:
386+
except (KeyError,OSError)aserr:
399387
warnings.warn(f'getpass.getuser() failed{err}.',RuntimeWarning)
400388
isbuildbot=False
401389
returnunittest.skipIf(isbuildbot,reason)
@@ -409,35 +397,48 @@ def check_sanitizer(*, address=False, memory=False, ub=False, thread=False):
409397
cflags=sysconfig.get_config_var('CFLAGS')or''
410398
config_args=sysconfig.get_config_var('CONFIG_ARGS')or''
411399
memory_sanitizer= (
412-
'-fsanitize=memory'incflagsor
413-
'--with-memory-sanitizer'inconfig_args
400+
'-fsanitize=memory'incflagsor
401+
'--with-memory-sanitizer'inconfig_args
414402
)
415403
address_sanitizer= (
416-
'-fsanitize=address'incflagsor
417-
'--with-address-sanitizer'inconfig_args
404+
'-fsanitize=address'incflagsor
405+
'--with-address-sanitizer'inconfig_args
418406
)
419407
ub_sanitizer= (
420-
'-fsanitize=undefined'incflagsor
421-
'--with-undefined-behavior-sanitizer'inconfig_args
408+
'-fsanitize=undefined'incflagsor
409+
'--with-undefined-behavior-sanitizer'inconfig_args
422410
)
423411
thread_sanitizer= (
424-
'-fsanitize=thread'incflagsor
425-
'--with-thread-sanitizer'inconfig_args
412+
'-fsanitize=thread'incflagsor
413+
'--with-thread-sanitizer'inconfig_args
426414
)
427415
return (
428-
(memoryandmemory_sanitizer)or
429-
(addressandaddress_sanitizer)or
430-
(ubandub_sanitizer)or
431-
(threadandthread_sanitizer)
416+
(memoryandmemory_sanitizer)or
417+
(addressandaddress_sanitizer)or
418+
(ubandub_sanitizer)or
419+
(threadandthread_sanitizer)
432420
)
433421

422+
434423
defskip_if_sanitizer(reason=None,*,address=False,memory=False,ub=False,thread=False):
435424
"""Decorator raising SkipTest if running with a sanitizer active."""
436425
ifnotreason:
437426
reason='not working with sanitizers active'
438-
skip=check_sanitizer(address=address,memory=memory,ub=ub)
427+
skip=check_sanitizer(address=address,memory=memory,ub=ub,thread=thread)
439428
returnunittest.skipIf(skip,reason)
440429

430+
# gh-89363: True if fork() can hang if Python is built with Address Sanitizer
431+
# (ASAN): libasan race condition, dead lock in pthread_create().
432+
HAVE_ASAN_FORK_BUG=check_sanitizer(address=True)
433+
434+
435+
defset_sanitizer_env_var(env,option):
436+
fornamein ('ASAN_OPTIONS','MSAN_OPTIONS','UBSAN_OPTIONS','TSAN_OPTIONS'):
437+
ifnameinenv:
438+
env[name]+=f':{option}'
439+
else:
440+
env[name]=option
441+
441442

442443
defsystem_must_validate_cert(f):
443444
"""Skip the test on TLS certificate validation failures."""
@@ -510,21 +511,42 @@ def has_no_debug_ranges():
510511
defrequires_debug_ranges(reason='requires co_positions / debug_ranges'):
511512
returnunittest.skipIf(has_no_debug_ranges(),reason)
512513

513-
defrequires_legacy_unicode_capi():
514+
@contextlib.contextmanager
515+
defsuppress_immortalization(suppress=True):
516+
"""Suppress immortalization of deferred objects."""
517+
try:
518+
import_testinternalcapi
519+
exceptImportError:
520+
yield
521+
return
522+
523+
ifnotsuppress:
524+
yield
525+
return
526+
527+
_testinternalcapi.suppress_immortalization(True)
528+
try:
529+
yield
530+
finally:
531+
_testinternalcapi.suppress_immortalization(False)
532+
533+
defskip_if_suppress_immortalization():
514534
try:
515-
from_testcapiimportunicode_legacy_string
535+
import_testinternalcapi
516536
exceptImportError:
517-
unicode_legacy_string=None
537+
return
538+
returnunittest.skipUnless(_testinternalcapi.get_immortalize_deferred(),
539+
"requires immortalization of deferred objects")
540+
518541

519-
returnunittest.skipUnless(unicode_legacy_string,
520-
'requires legacy Unicode C API')
542+
MS_WINDOWS= (sys.platform=='win32')
521543

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

525-
is_android=hasattr(sys,'getandroidapilevel')
547+
is_android=sys.platform=="android"
526548

527-
ifsys.platformnotin('win32','vxworks'):
549+
ifsys.platformnotin{"win32","vxworks","ios","tvos","watchos"}:
528550
unix_shell='/system/bin/sh'ifis_androidelse'/bin/sh'
529551
else:
530552
unix_shell=None
@@ -534,23 +556,44 @@ def requires_legacy_unicode_capi():
534556
is_emscripten=sys.platform=="emscripten"
535557
is_wasi=sys.platform=="wasi"
536558

537-
has_fork_support=hasattr(os,"fork")andnotis_emscriptenandnotis_wasi
559+
is_apple_mobile=sys.platformin {"ios","tvos","watchos"}
560+
is_apple=is_apple_mobileorsys.platform=="darwin"
538561

539-
# From python 3.12.6
540-
is_s390x=hasattr(os,'uname')andos.uname().machine=='s390x'
541-
skip_on_s390x=unittest.skipIf(is_s390x,'skipped on s390x')
562+
has_fork_support=hasattr(os,"fork")andnot (
563+
# WASM and Apple mobile platforms do not support subprocesses.
564+
is_emscripten
565+
oris_wasi
566+
oris_apple_mobile
567+
568+
# Although Android supports fork, it's unsafe to call it from Python because
569+
# all Android apps are multi-threaded.
570+
oris_android
571+
)
542572

543573
defrequires_fork():
544574
returnunittest.skipUnless(has_fork_support,"requires working os.fork()")
545575

546-
has_subprocess_support=notis_emscriptenandnotis_wasi
576+
has_subprocess_support=not (
577+
# WASM and Apple mobile platforms do not support subprocesses.
578+
is_emscripten
579+
oris_wasi
580+
oris_apple_mobile
581+
582+
# Although Android supports subproceses, they're almost never useful in
583+
# practice (see PEP 738). And most of the tests that use them are calling
584+
# sys.executable, which won't work when Python is embedded in an Android app.
585+
oris_android
586+
)
547587

548588
defrequires_subprocess():
549589
"""Used for subprocess, os.spawn calls, fd inheritance"""
550590
returnunittest.skipUnless(has_subprocess_support,"requires subprocess support")
551591

552592
# Emscripten's socket emulation and WASI sockets have limitations.
553-
has_socket_support=notis_emscriptenandnotis_wasi
593+
has_socket_support=not (
594+
is_emscripten
595+
oris_wasi
596+
)
554597

555598
defrequires_working_socket(*,module=False):
556599
"""Skip tests or modules that require working sockets
@@ -2551,7 +2594,8 @@ def adjust_int_max_str_digits(max_digits):
25512594
# The default C recursion limit (from Include/cpython/pystate.h).
25522595
C_RECURSION_LIMIT=1500
25532596

2554-
#Windows doesn't have os.uname() but it doesn't support s390x.
2597+
# Windows doesn't have os.uname() but it doesn't support s390x.
2598+
is_s390x=hasattr(os,'uname')andos.uname().machine=='s390x'
25552599
skip_on_s390x=unittest.skipIf(hasattr(os,'uname')andos.uname().machine=='s390x',
25562600
'skipped on s390x')
25572601
HAVE_ASAN_FORK_BUG=check_sanitizer(address=True)

‎Lib/test/test_csv.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,18 +291,6 @@ def test_writerows_errors(self):
291291
self.assertRaises(TypeError,writer.writerows,None)
292292
self.assertRaises(OSError,writer.writerows,BadIterable())
293293

294-
@support.cpython_only
295-
@support.requires_legacy_unicode_capi()
296-
@warnings_helper.ignore_warnings(category=DeprecationWarning)
297-
deftest_writerows_legacy_strings(self):
298-
import_testcapi
299-
c=_testcapi.unicode_legacy_string('a')
300-
withTemporaryFile("w+",encoding="utf-8",newline='')asfileobj:
301-
writer=csv.writer(fileobj)
302-
writer.writerows([[c]])
303-
fileobj.seek(0)
304-
self.assertEqual(fileobj.read(),"a\r\n")
305-
306294
def_read_test(self,input,expect,**kwargs):
307295
reader=csv.reader(input,**kwargs)
308296
result=list(reader)

‎Lib/test/test_decimal.py

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
importlocale
3535
fromtest.supportimport (is_resource_enabled,
3636
requires_IEEE_754,requires_docstrings,
37-
requires_legacy_unicode_capi,check_sanitizer)
37+
check_disallow_instantiation)
3838
fromtest.supportimport (TestFailed,
3939
run_with_locale,cpython_only,
40-
darwin_malloc_err_warning,is_emscripten)
40+
darwin_malloc_err_warning)
4141
fromtest.support.import_helperimportimport_fresh_module
4242
fromtest.supportimportthreading_helper
4343
fromtest.supportimportwarnings_helper
@@ -586,18 +586,6 @@ def test_explicit_from_string(self):
586586
# underscores don't prevent errors
587587
self.assertRaises(InvalidOperation,Decimal,"1_2_\u00003")
588588

589-
@cpython_only
590-
@requires_legacy_unicode_capi()
591-
@warnings_helper.ignore_warnings(category=DeprecationWarning)
592-
deftest_from_legacy_strings(self):
593-
import_testcapi
594-
Decimal=self.decimal.Decimal
595-
context=self.decimal.Context()
596-
597-
s=_testcapi.unicode_legacy_string('9.999999')
598-
self.assertEqual(str(Decimal(s)),'9.999999')
599-
self.assertEqual(str(context.create_decimal(s)),'9.999999')
600-
601589
deftest_explicit_from_tuples(self):
602590
Decimal=self.decimal.Decimal
603591

@@ -2928,23 +2916,6 @@ def test_none_args(self):
29282916
assert_signals(self,c,'traps', [InvalidOperation,DivisionByZero,
29292917
Overflow])
29302918

2931-
@cpython_only
2932-
@requires_legacy_unicode_capi()
2933-
@warnings_helper.ignore_warnings(category=DeprecationWarning)
2934-
deftest_from_legacy_strings(self):
2935-
import_testcapi
2936-
c=self.decimal.Context()
2937-
2938-
forrndinRoundingModes:
2939-
c.rounding=_testcapi.unicode_legacy_string(rnd)
2940-
self.assertEqual(c.rounding,rnd)
2941-
2942-
s=_testcapi.unicode_legacy_string('')
2943-
self.assertRaises(TypeError,setattr,c,'rounding',s)
2944-
2945-
s=_testcapi.unicode_legacy_string('ROUND_\x00UP')
2946-
self.assertRaises(TypeError,setattr,c,'rounding',s)
2947-
29482919
deftest_pickle(self):
29492920

29502921
forprotoinrange(pickle.HIGHEST_PROTOCOL+1):
@@ -5654,48 +5625,6 @@ def __abs__(self):
56545625
self.assertEqual(Decimal.from_float(cls(101.1)),
56555626
Decimal.from_float(101.1))
56565627

5657-
# Issue 41540:
5658-
@unittest.skipIf(sys.platform.startswith("aix"),
5659-
"AIX: default ulimit: test is flaky because of extreme over-allocation")
5660-
@unittest.skipIf(is_emscripten,"Test is unstable on Emscripten")
5661-
@unittest.skipIf(check_sanitizer(address=True,memory=True),
5662-
"ASAN/MSAN sanitizer defaults to crashing "
5663-
"instead of returning NULL for malloc failure.")
5664-
deftest_maxcontext_exact_arith(self):
5665-
5666-
# Make sure that exact operations do not raise MemoryError due
5667-
# to huge intermediate values when the context precision is very
5668-
# large.
5669-
5670-
# The following functions fill the available precision and are
5671-
# therefore not suitable for large precisions (by design of the
5672-
# specification).
5673-
MaxContextSkip= ['logical_invert','next_minus','next_plus',
5674-
'logical_and','logical_or','logical_xor',
5675-
'next_toward','rotate','shift']
5676-
5677-
Decimal=C.Decimal
5678-
Context=C.Context
5679-
localcontext=C.localcontext
5680-
5681-
# Here only some functions that are likely candidates for triggering a
5682-
# MemoryError are tested. deccheck.py has an exhaustive test.
5683-
maxcontext=Context(prec=C.MAX_PREC,Emin=C.MIN_EMIN,Emax=C.MAX_EMAX)
5684-
withlocalcontext(maxcontext):
5685-
self.assertEqual(Decimal(0).exp(),1)
5686-
self.assertEqual(Decimal(1).ln(),0)
5687-
self.assertEqual(Decimal(1).log10(),0)
5688-
self.assertEqual(Decimal(10**2).log10(),2)
5689-
self.assertEqual(Decimal(10**223).log10(),223)
5690-
self.assertEqual(Decimal(10**19).logb(),19)
5691-
self.assertEqual(Decimal(4).sqrt(),2)
5692-
self.assertEqual(Decimal("40E9").sqrt(),Decimal('2.0E+5'))
5693-
self.assertEqual(divmod(Decimal(10),3), (3,1))
5694-
self.assertEqual(Decimal(10)//3,3)
5695-
self.assertEqual(Decimal(4)/2,2)
5696-
self.assertEqual(Decimal(400)**-1,Decimal('0.0025'))
5697-
5698-
56995628
deftest_c_signaldict_segfault(self):
57005629
# See gh-106263 for details.
57015630
SignalDict=type(C.Context().flags)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp