repo
stringclasses
1 value
instance_id
stringlengths
20
22
problem_statement
stringlengths
126
60.8k
merge_commit
stringlengths
40
40
base_commit
stringlengths
40
40
python/cpython
python__cpython-132389
# Increase test coverage for HMAC # Feature or enhancement ### Proposal: After implementing HACL* HMAC in #99108, I've observed that I didn't test all code paths and that some tests I assumed were a bit incorrect (some redundancy was done). This is an issue to track all improvements done to HMAC tests (I'm planning to target an almost 100% coverage), but I'll close it when nothing needs to be done "for now". ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-132389 * gh-132480 * gh-133008 * gh-134051 * gh-134089 <!-- /gh-linked-prs -->
a1cd4ca7f46eafe61dc7f26692896a4a95c7e947
084d6dc122c761b90cba620eac2f25dc1660b7f1
python/cpython
python__cpython-132412
# Segfault or failed assertion (`obj != NULL`) in `PyStackRef_FromPyObjectSteal` # Crash report ### What happened? It's possible to segfault or abort the interpreter with the following code: ```python class WeirdDict(dict): pass ns = {} exec("def __create_fn__():\n return a", WeirdDict({None: None}), ns) ns['__create_fn__']() ``` Segfault backtrace: ```gdb Program received signal SIGSEGV, Segmentation fault. _PyEval_LoadGlobalStackRef (globals=<optimized out>, builtins=<optimized out>, name=0x555555aeace0 <_PyRuntime+80128>, writeto=0x7ffff7fb00f8) at Python/ceval.c:3317 3317 *writeto = PyStackRef_FromPyObjectSteal(res); (gdb) bt #0 _PyEval_LoadGlobalStackRef (globals=<optimized out>, builtins=<optimized out>, name=0x555555aeace0 <_PyRuntime+80128>, writeto=0x7ffff7fb00f8) at Python/ceval.c:3317 #1 0x00005555555e22f2 in _PyEval_EvalFrameDefault (tstate=0x555555b24178 <_PyRuntime+314776>, frame=<optimized out>, throwflag=<optimized out>) at Python/generated_cases.c.h:9073 #2 0x00005555557ab807 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb0020, tstate=0x555555b24178 <_PyRuntime+314776>) at ./Include/internal/pycore_ceval.h:119 #3 _PyEval_Vector (args=0x0, argcount=0, kwnames=0x0, locals=0x7ffff7a4d240, func=0x7ffff7a50f60, tstate=0x555555b24178 <_PyRuntime+314776>) at Python/ceval.c:1913 #4 PyEval_EvalCode (co=co@entry=0x7ffff7bf5920, globals=globals@entry=0x7ffff7a4d240, locals=locals@entry=0x7ffff7a4d240) at Python/ceval.c:829 #5 0x000055555581f3bc in run_eval_code_obj (locals=0x7ffff7a4d240, globals=0x7ffff7a4d240, co=0x7ffff7bf5920, tstate=0x555555b24178 <_PyRuntime+314776>) at Python/pythonrun.c:1365 #6 run_mod (mod=<optimized out>, filename=filename@entry=0x7ffff7a066b0, globals=globals@entry=0x7ffff7a4d240, locals=locals@entry=0x7ffff7a4d240, flags=flags@entry=0x7fffffffdc18, arena=arena@entry=0x7ffff7b5e210, interactive_src=0x0, generate_new_source=0) at Python/pythonrun.c:1436 #7 0x0000555555821456 in pyrun_file (flags=0x7fffffffdc18, closeit=1, locals=0x7ffff7a4d240, globals=0x7ffff7a4d240, start=257, filename=0x7ffff7a066b0, fp=0x555555b97510) at Python/pythonrun.c:1293 ``` Abort backtrace: ```gdb python: ./Include/internal/pycore_stackref.h:447: PyStackRef_FromPyObjectSteal: Assertion `obj != NULL' failed. Program received signal SIGABRT, Aborted. __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:44 44 ./nptl/pthread_kill.c: No such file or directory. (gdb) bt #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=140737350580032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3 0x00007ffff7ce0476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4 0x00007ffff7cc67f3 in __GI_abort () at ./stdlib/abort.c:79 #5 0x00007ffff7cc671b in __assert_fail_base ( fmt=0x7ffff7e7b130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555555a5971d "obj != NULL", file=0x5555559dc630 "./Include/internal/pycore_stackref.h", line=447, function=<optimized out>) at ./assert/assert.c:94 #6 0x00007ffff7cd7e96 in __GI___assert_fail (assertion=assertion@entry=0x555555a5971d "obj != NULL", file=file@entry=0x5555559dc630 "./Include/internal/pycore_stackref.h", line=line@entry=447, function=function@entry=0x555555a42180 <__PRETTY_FUNCTION__.23> "PyStackRef_FromPyObjectSteal") at ./assert/assert.c:103 #7 0x0000555555829da7 in PyStackRef_FromPyObjectSteal (obj=<optimized out>) at ./Include/internal/pycore_stackref.h:447 #8 _PyEval_LoadGlobalStackRef (globals=<optimized out>, builtins=<optimized out>, name='a', writeto=writeto@entry=0x7ffff7fb00f8) at Python/ceval.c:3312 #9 0x000055555584e4ba in _PyEval_EvalFrameDefault ( tstate=tstate@entry=0x555555c69558 <_PyRuntime+330424>, frame=0x7ffff7fb00a8, frame@entry=0x7ffff7fb0020, throwflag=throwflag@entry=0) at Python/generated_cases.c.h:9086 #10 0x000055555585cd69 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb0020, tstate=0x555555c69558 <_PyRuntime+330424>) at ./Include/internal/pycore_ceval.h:119 ``` Found using [fusil](https://github.com/devdanzin/fusil) by @vstinner. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux, Windows ### Output from running 'python -VV' on the command line: Python 3.14.0a7+ (heads/main:d87e7f35297, Apr 11 2025, 06:20:25) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-132412 <!-- /gh-linked-prs -->
e6ef47ac229b5c4a62b9c907e4232e350db77ce3
deda47d6e18d61e982045b795e3599838823db6a
python/cpython
python__cpython-132387
# Instance attr error suggestions can execute `__getattr__` # Bug report ```python >>> class A: ... def __getattr__(self, key): ... if key == 'foo': raise SystemExit('bye') ... def bar(self): ... foo ... >>> A().bar() bye # interperter exits :( ``` Originally found by @millerdev in https://github.com/python/cpython/pull/99140#issuecomment-2794364711 I think that this is not ideal. We probably want to silence all errors. I have a PR ready. <!-- gh-linked-prs --> ### Linked PRs * gh-132387 * gh-133297 <!-- /gh-linked-prs -->
641253cfac789e57c2b0c16047bdbf355535f60f
20f8ed595d176d951a09eba045cd69ca62981b18
python/cpython
python__cpython-132357
# test_pathlib - test_group_no_follow_symlinks resolves group name from uid rather than gid # Bug report ### Bug description: In Fedora 43 `test_group_no_follow_symlinks` started failing with a peculiar failure for Python 3.14 and Python 3.13: ```pytb ====================================================================== FAIL: test_group_no_follow_symlinks (test.test_pathlib.test_pathlib.PathSubclassTest.test_group_no_follow_symlinks) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib64/python3.14/test/test_pathlib/test_pathlib.py", line 2071, in test_group_no_follow_symlinks self.assertEqual(expected_name, link.group(follow_symlinks=False)) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: 'adm' != 'sys' - adm + sys ====================================================================== FAIL: test_group_no_follow_symlinks (test.test_pathlib.test_pathlib.PathTest.test_group_no_follow_symlinks) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib64/python3.14/test/test_pathlib/test_pathlib.py", line 2071, in test_group_no_follow_symlinks self.assertEqual(expected_name, link.group(follow_symlinks=False)) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: 'adm' != 'sys' - adm + sys ====================================================================== FAIL: test_group_no_follow_symlinks (test.test_pathlib.test_pathlib.PosixPathTest.test_group_no_follow_symlinks) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib64/python3.14/test/test_pathlib/test_pathlib.py", line 2071, in test_group_no_follow_symlinks self.assertEqual(expected_name, link.group(follow_symlinks=False)) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: 'adm' != 'sys' - adm + sys ``` The gid, which is asserted the line above, is in both cases the same (`3`), but the names don't match. The tests calls `_get_pw_name_or_skip_test`, which calls `pwd.getpwuid(uid).pw_name` - which in return stopped giving the right result in our environment. https://github.com/python/cpython/blob/29af6cee02fbe74d59c6d725a506fe60c77d37d6/Lib/test/test_pathlib/test_pathlib.py#L2068 The cut contents of the two system files (you can check it for yourself spawning the fedora:rawhide container with `podman run -rm -it fedora:rawhide /usr/bin/bash`): ``` bash-5.2# head /etc/group root:x:0: sys:x:3: adm:x:4: bash-5.2# head /etc/passwd root:x:0:0:Super User:/root:/bin/bash bin:x:1:1:bin:/bin:/usr/bin/nologin daemon:x:2:2:daemon:/sbin:/usr/bin/nologin adm:x:3:4:adm:/var/adm:/usr/bin/nologin ``` I believe the test should use the other helper function prepared `_get_gr_name_or_skip_test`. It was probably an accidental copy-paste omission in the first place. I verified this will make the tests pass. ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132357 * gh-132404 <!-- /gh-linked-prs -->
3e1a47bdb468d02665c137d84dd44500a557b58b
f23052591a60f588c432795f1ac687e709d97386
python/cpython
python__cpython-132374
# AsyncIO-Docs: Task.cancel return value not documented # Documentation The documentation of [`asyncio.Task.cancel`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel) does not mention that there is a return value of True/False. The return value functions like the one of [`asyncio.Future.cancel`](https://docs.python.org/3/library/asyncio-future.html#asyncio.Future.cancel), where `False` indicates it was already done or cancelled. The only reference is that `Task`s are "Future-like objects". Other Functions state the return value either as first, or second paragraph. <!-- gh-linked-prs --> ### Linked PRs * gh-132374 * gh-132465 <!-- /gh-linked-prs -->
64b066ad298506f715647c9a2524c9fbbc764cc2
f69b344e0944bd8d59d2dc4d98e988cc4dbfadf3
python/cpython
python__cpython-132352
# Reference counting related regression in Python 3.14a7? # Bug report ### Bug description: Dear Python team, I am the lead of the [nanobind](https://github.com/wjakob/nanobind) project, which is a C++<->Python binding tool. I always try to follow recent Python versions to react to any API/ABI changes and catch issues before they end up in public releases. With the just-released Python 3.14a7, a whole bunch of testcases in the nanobind test suite start to fail (example: https://github.com/wjakob/nanobind/actions/runs/14372986244/job/40299387939). These are all tests that create and pass objects and expect reference counts to behave in a certain way. This works consistently for PyPy and all tested CPython version from 3.8 all the way until 3.14a6, and so it is therefore surprising to see such a change in behavior in an alpha version bump. I'm wondering what could cause this? Are there known issues in 3.14a7? Did reference counting / garbage collection change in some way that could cause such behavior to arise? Thank you, Wenzel ### CPython versions tested on: 3.14 ### Operating systems tested on: macOS, Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132352 * gh-136613 * gh-136614 <!-- /gh-linked-prs -->
3dbe02ccd3eefc48ac9fa14427bb4cdb82d1ebae
9e5cebd56d06e35faeca166813215d72f2f8906a
python/cpython
python__cpython-132332
# `typestruct.h` is outdated compared to implementation # Documentation `Doc/includes/typestruct.h` contains a copy of `_typeobject` from `Include/cpython/object.h`, but it is currently outdated. <!-- gh-linked-prs --> ### Linked PRs * gh-132332 <!-- /gh-linked-prs -->
e329f74e7d24be6ae1782b5ab90e20723aa47bcd
d687900f98114bb5910daad9553ae381d7daf94b
python/cpython
python__cpython-132348
# Test failures when hypothesis is available but cannot reach GitHub # Bug report ### Bug description: Hi, we recently started seeing several tests (namely `test_binascii`, `test_math_property`, `test_tools` and `test_zoneinfo`) to fail due to hypothesis warnings (which were recently turned into errors with https://github.com/python/cpython/pull/131802): ``` hypothesis.errors.HypothesisWarning: Authorization failed when trying to download artifact from GitHub. Check that you have a valid GITHUB_TOKEN set in your environment.` ``` or alternatively with ``` hypothesis.errors.HypothesisWarning: Could not connect to GitHub to get the latest artifact. ``` when I restrict the access to the internet. I see that running with `"CI"` set in the environment fixes the issue as the problematic profile with `GitHubArtifactDatabase` is not registered, but that seems more like a lucky workaround. I am not sure about the solution - maybe it can check whether `"GITHUB_TOKEN"` is also available? Or maybe the warning should be ignored and not cause the tests to fail. I also think it should honor `-urlfetch` and `-network` options. ### CPython versions tested on: 3.13 ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-132348 * gh-132367 <!-- /gh-linked-prs -->
fcf2d07228ada64bc864380cd8e3e304d9768caa
65357032e80f8750dd102c82a8adc54de067fc38
python/cpython
python__cpython-132363
# `TracebackException` swallows attributes of falsey Exception and falsey ExceptionGroup. # Bug report ### Bug description: # Description ``` import traceback as tb class FalseyLenException(Exception): def __len__(self): return 0 class FalseyBoolException(Exception): def __bool__(self): return False def tracebackexception_swallows_cause_and_context(): try: raise FalseyBoolException("Oh") from KeyError except Exception as e: print(f'{e = }, {e.__cause__ = }') tb.print_exception(e) print("---"*20) try: try: 1/0 except: raise FalseyLenException("Ah") except Exception as e: print(f'{e = }, {e.__context__ = }') tb.print_exception(e) print("---"*20) if __name__ == "__main__": tracebackexception_swallows_cause_and_context() ``` Ouptput is: ``` e = FalseyBoolException('Oh'), e.__cause__ = KeyError() Traceback (most recent call last): File "/Users/yves/Desktop/Bugs/gh-132XXX.py", line 13, in tracebackexception_swallows_cause_and_context raise FalseyBoolException("Oh") from KeyError FalseyBoolException: Oh ------------------------------------------------------------ e = FalseyLenException('Ah'), e.__context__ = ZeroDivisionError('division by zero') Traceback (most recent call last): File "/Users/yves/Desktop/Bugs/gh-132XXX.py", line 23, in tracebackexception_swallows_cause_and_context raise FalseyLenException("Ah") FalseyLenException: Ah ``` The **Cause** or **Context** descriptions are not printed as expected. # Where Does it from ? These following tests are wrong. https://github.com/python/cpython/blob/255eb375a7cc3cb16698bebf42689e8bc783ed93/Lib/traceback.py#L1123 It should be: `if (e is not None and e.__cause__ is not None` https://github.com/python/cpython/blob/255eb375a7cc3cb16698bebf42689e8bc783ed93/Lib/traceback.py#L1144 It should be: `if (e is not None and and e.__context__ is not None` # Linked Issues See: https://github.com/python/cpython/pull/132129 ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-132363 * gh-132725 <!-- /gh-linked-prs -->
69cda31261dd98b0462dc5ca63bdbcd0954dfa77
427e7fc099e61d9a3d1f04e2fbde8b749e5fcf0a
python/cpython
python__cpython-132324
# Inconsistent code found by static analyzers at base_events.py Greetings! I've been analyzing Cpython with Svace static analyzer. It has found a code inconsitency issue at the `asyncio` library in the following method: https://github.com/python/cpython/blob/7ebbd271444d89218870169624921b795a717470/Lib/asyncio/base_events.py#L1653-L1681 The problem is a redundant comparison with a `None` value for reference `sock` here: https://github.com/python/cpython/blob/7ebbd271444d89218870169624921b795a717470/Lib/asyncio/base_events.py#L1669-L1670 which has already been dereferenced before: https://github.com/python/cpython/blob/7ebbd271444d89218870169624921b795a717470/Lib/asyncio/base_events.py#L1658-L1659 According to the [documentation](https://docs.python.org/3/library/asyncio-eventloop.html#:~:text=sock%20is%20a%20preexisting%20socket%20object%20returned%20from%20socket.accept), the `sock` input parameter is a preexisting object returned from the `socket.accept()` function. So it shouldn't be `None` --- ### Proposed solution I believe it is advisable to either move the null check for `sock` to the beginning of the function, or remove it. I'm not sure which of these options would be more in line with the regulations. After I get a response, I might be able to create a pull request. <!-- gh-linked-prs --> ### Linked PRs * gh-132324 <!-- /gh-linked-prs -->
a214db0c5406254d293f33622ce2cbd8233b52a5
1557da622c89985d14b781bef91e9aaa6e1f88c4
python/cpython
python__cpython-132306
# Argument Clinic code is incompatible with older Python Until recently I used Python 3.11 to regenerate Argument Clinic code. But `make clinic` stopped to work because Python code for some Argument Clinic converted uses syntax incompatible with 3.11. We should be conservative with Python code that is used to build Python. <!-- gh-linked-prs --> ### Linked PRs * gh-132306 <!-- /gh-linked-prs -->
487cf3c1702836dfce0025208b989853681d2cd9
4a919dd6eef1e5dbaddfd749f385f49cedc076a9
python/cpython
python__cpython-132286
# `__annotate__` corner case when deleting `__annotations__` Consider this example: ```python >>> class A: ... def __annotate__(format): ... print(f'{format=}') ... return {'a': int} ... >>> A.__annotations__ format=1 {'a': <class 'int'>} >>> A.__annotations__ {'a': <class 'int'>} >>> del A.__annotations__ >>> A.__annotations__ format=1 {'a': <class 'int'>} ``` In this particular case `__annotate__` is called twice. It works correctly in my opinion. But, I can't find any tests for such cases. Should I add tests for this? CC @JelleZijlstra <!-- gh-linked-prs --> ### Linked PRs * gh-132286 <!-- /gh-linked-prs -->
254110356d17204d2aebb9e74b6074cc6ef6382e
1f5682f3a27516833f7c317707dd359280dba6e7
python/cpython
python__cpython-132329
# Py_TYPE(lhs)->tp_as_mapping->mp_subscript is not the same as Dict_Type.tp_as_mapping->mp_subscript when it should be A dict subclass which does not override `__getitem__` (like `collections.Counter`) should have `Dict_Type.tp_as_mapping->mp_subscript` as its `Py_TYPE(lhs)->tp_as_mapping->mp_subscript`, but they are not the same. CC @ericsnowcurrently . <!-- gh-linked-prs --> ### Linked PRs * gh-132329 <!-- /gh-linked-prs -->
a23ed8b3793aa684e312711cfda9c9fd76168399
5707837049e8eade92e29f20f055112821b75cd0
python/cpython
python__cpython-132345
# [3.14] annotationlib - calling `get_annotations` on instances gets an unexpected error # Bug report ### Bug description: In 3.13, `inspect.get_annotations` would fail if called on instances and give you a `TypeError` explaining as much. In 3.14 if you call `annotationlib.get_annotations(inst, format=Format.STRING)` on an instance you currently get a more confusing error. ```python from annotationlib import get_annotations, Format class Example: a: int ex = Example() print(get_annotations(ex, format=Format.STRING)) ``` ``` Traceback (most recent call last): File "<python-input-8>", line 9, in <module> print(get_annotations(ex, format=Format.STRING)) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/david/src/cpython/Lib/annotationlib.py", line 719, in get_annotations ann = _get_and_call_annotate(obj, format) File "/home/david/src/cpython/Lib/annotationlib.py", line 826, in _get_and_call_annotate ann = call_annotate_function(annotate, format, owner=obj) File "/home/david/src/cpython/Lib/annotationlib.py", line 513, in call_annotate_function return annotate(format) TypeError: Example.__annotate__() takes 1 positional argument but 2 were given ``` As far as I can tell this appears to be because `__annotate__` has turned into a bound method. You currently only see this if you use `Format.STRING` due to https://github.com/python/cpython/issues/125618 masking the issue, as with both other formats if `__annotations__` has been created on the class it is used instead of calling `__annotate__` and if it doesn't you get an empty dict. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-132345 <!-- /gh-linked-prs -->
07b8d3117fdbc4e5be55aab0be428c278ec84e12
e5f68fd29b3bd867207f23608a8dbc5759a056ed
python/cpython
python__cpython-132258
# Our GCC LTO flags can be improved # Feature or enhancement ### Proposal: @thesamesam pointed out to me that our GCC LTO configuration builds serially and as a single translation unit IIUC. This is the slowest configuration possible. On GCC 15, the LTO build takes 10m14.972s, in my first PR, it takes 2m28.287s. This is a multiple factor reduction in build times. Benchmarks show basically no change in performance --- 1.004x slower on one machine, and 1.000x faster on another machine. This is basically in the realm of noise. https://github.com/faster-cpython/benchmarking-public/tree/main/results/bm-20250407-3.14.0a6+-8891cd2 ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-132258 <!-- /gh-linked-prs -->
bc0b94b30c9d65ba550daee2c2ef20035defd980
07b8d3117fdbc4e5be55aab0be428c278ec84e12
python/cpython
python__cpython-132251
# `_ccall_callback` method of `_lsprof.Profiler` causes Fatal Python error # Crash report ### What happened? When a `_lsprof.Profiler` is enabled and a `TypeError` is raised from mismatching descriptor and target, a Fatal Python error happens due to `_ccall_callback ` returning a result with an exception set: ```python import _lsprof prof = _lsprof.Profiler() prof.enable() def mismatch(first, second): first.find(second()) mismatch(bytes, str) # mismatch(str, bytes) # mismatch(str, list) Fatal Python error: _Py_CheckFunctionResult: a function returned a result with an exception set Python runtime state: initialized TypeError: descriptor 'find' for 'bytes' objects doesn't apply to a 'str' object The above exception was the direct cause of the following exception: SystemError: <built-in method _ccall_callback of _lsprof.Profiler object at 0x20000922f10> returned a result with an exception set Stack (most recent call first): File "/mnt/c/Users/ddini/crashers/main/cProfile-fatal_python_error-abort/source2.py", line 7 in mismatch File "/mnt/c/Users/ddini/crashers/main/cProfile-fatal_python_error-abort/source2.py", line 9 in <module> Program received signal SIGABRT, Aborted. ``` Backtrace: ``` #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=140737350580032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3 0x00007ffff7ce0476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4 0x00007ffff7cc67f3 in __GI_abort () at ./stdlib/abort.c:79 #5 0x000055555590ba45 in fatal_error_exit (status=<optimized out>) at Python/pylifecycle.c:3140 #6 0x000055555591879a in fatal_error (fd=2, header=header@entry=1, prefix=prefix@entry=0x555555a27b40 <__func__.23> "_Py_CheckFunctionResult", msg=msg@entry=0x555555a275a0 "a function returned a result with an exception set", status=status@entry=-1) at Python/pylifecycle.c:3356 #7 0x000055555591880c in _Py_FatalErrorFunc (func=func@entry=0x555555a27b40 <__func__.23> "_Py_CheckFunctionResult", msg=msg@entry=0x555555a275a0 "a function returned a result with an exception set") at Python/pylifecycle.c:3372 #8 0x000055555567dfe8 in _Py_CheckFunctionResult (tstate=tstate@entry=0x555555cd6498 <_PyRuntime+361432>, callable=callable@entry=<built-in method _ccall_callback of _lsprof.Profiler object at remote 0x20000922f10>, result=<optimized out>, where=where@entry=0x0) at Objects/call.c:65 #9 0x00005555558f1298 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=9223372036854775812, args=0x7fffffffd478, callable=<built-in method _ccall_callback of _lsprof.Profiler object at remote 0x20000922f10>, tstate=0x555555cd6498 <_PyRuntime+361432>) at ./Include/internal/pycore_call.h:170 #10 call_one_instrument (interp=interp@entry=0x555555c9de40 <_PyRuntime+130432>, tstate=tstate@entry=0x555555cd6498 <_PyRuntime+361432>, args=args@entry=0x7fffffffd478, nargsf=nargsf@entry=9223372036854775812, tool=tool@entry=2 '\002', event=event@entry=4) at Python/instrumentation.c:985 #11 0x00005555558f373f in call_instrumentation_vector (instr=instr@entry=0x200009f241c, tstate=tstate@entry=0x555555cd6498 <_PyRuntime+361432>, event=event@entry=4, frame=frame@entry=0x7ffff7fb0090, arg2=arg2@entry=0x200009f241c, nargs=<optimized out>, nargs@entry=4, args=0x7fffffffd470) at Python/instrumentation.c:1172 #12 0x00005555558f5d65 in _Py_call_instrumentation_2args (tstate=tstate@entry=0x555555cd6498 <_PyRuntime+361432>, event=event@entry=4, frame=frame@entry=0x7ffff7fb0090, instr=instr@entry=0x200009f241c, arg0=<optimized out>, arg1=<optimized out>) at Python/instrumentation.c:1227 #13 0x0000555555867263 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555cd6498 <_PyRuntime+361432>, frame=0x7ffff7fb0090, frame@entry=0x7ffff7fb0020, throwflag=throwflag@entry=0) at Python/generated_cases.c.h:6122 #14 0x00005555558859f2 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb0020, tstate=0x555555cd6498 <_PyRuntime+361432>) at ./Include/internal/pycore_ceval.h:119 ``` Found using [fusil](https://github.com/devdanzin/fusil) by @vstinner. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.14.0a6+ (heads/main:be2d2181e62, Mar 31 2025, 07:30:17) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-132251 * gh-132281 <!-- /gh-linked-prs -->
ab64130b572424695bf072f7608a536997dce14f
efd8aca62c214dde6115822a659403fb05340680
python/cpython
python__cpython-132247
# Add PEP 688 special buffer methods to C API Type Object and Buffer Protocol docs # Documentation Two special methods, `__buffer__` and `__release_buffer__` were added to Python 3.12 by PEP-688. The C API Type Object documentation for slots includes `tp_as_buffer`, and sub-slots `bf_getbuffer`, `bf_releasebuffer` but does not refer to the Python Data Model version of those. Add the missing references. C API Type Object: https://docs.python.org/3/c-api/typeobj.html#tp-slots Data Model: https://docs.python.org/3/reference/datamodel.html#emulating-buffer-types <!-- gh-linked-prs --> ### Linked PRs * gh-132247 * gh-132249 * gh-132282 * gh-134426 * gh-134427 <!-- /gh-linked-prs -->
b529b60fc239d19245e5fafd0514d90097c2eb40
d862b6de1bcff01229318d7138ddaab755723a43
python/cpython
python__cpython-132222
# `dataclasses` docs do not mention that `kw_only` fields are ignored from `__match_args__` # Bug report # Documentation Docs right now: https://docs.python.org/3.14/library/dataclasses.html#dataclasses.dataclass ``` match_args: If true (the default is True), the [__match_args__](https://docs.python.org/3.14/reference/datamodel.html#object.__match_args__) tuple will be created from the list of parameters to the generated [__init__()](https://docs.python.org/3.14/reference/datamodel.html#object.__init__) method (even if __init__() is not generated, see above). If false, or if __match_args__ is already defined in the class, then __match_args__ will not be generated. ``` But, in runtime this does not work this way: ```python >>> import dataclasses >>> @dataclasses.dataclass(kw_only=True) ... class A: ... a: int ... >>> print(A.__match_args__) () ``` It only add non-kw-only params here: - https://github.com/python/cpython/blob/895d983b5c9716aaaab34d14d278084b9b6730d8/Lib/dataclasses.py#L1174-L1177 - https://github.com/python/cpython/blob/895d983b5c9716aaaab34d14d278084b9b6730d8/Lib/dataclasses.py#L411-L417 Found while working on https://github.com/python/mypy/pull/18892 I have a PR ready. Thanks to @sterliakov! <!-- gh-linked-prs --> ### Linked PRs * gh-132222 * gh-132226 * gh-132227 <!-- /gh-linked-prs -->
8b62374b344f5da852bed9f16619736d4d43936b
e80ed2cf75384bab09e70f0f04d17e92183fdf12
python/cpython
python__cpython-132215
# Data race between set_richcompare and frozenset_hash under free-threading # Bug report ### Bug description: We have the following TSAN report from coming JAX CI: ``` ================== WARNING: ThreadSanitizer: data race (pid=40645) Read of size 8 at 0x7fffb6bdc1a0 by thread T6 (mutexes: read M0): #0 set_richcompare /__w/jax/jax/cpython/Objects/setobject.c:2144:16 (python3.14+0x2e1904) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) #1 do_richcompare /__w/jax/jax/cpython/Objects/object.c:1054:15 (python3.14+0x2a644b) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) #2 PyObject_RichCompare /__w/jax/jax/cpython/Objects/object.c:1103:21 (python3.14+0x2a644b) #3 _PyEval_EvalFrameDefault /__w/jax/jax/cpython/Python/generated_cases.c.h:4471:35 (python3.14+0x40690b) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) #4 _PyEval_EvalFrame /__w/jax/jax/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.14+0x3f7550) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) #5 _PyEval_Vector /__w/jax/jax/cpython/Python/ceval.c:1902:12 (python3.14+0x3f7550) #6 _PyFunction_Vectorcall /__w/jax/jax/cpython/Objects/call.c (python3.14+0x1f1a8f) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) #7 _PyObject_VectorcallTstate /__w/jax/jax/cpython/./Include/internal/pycore_call.h:169:11 (python3.14+0x2f9e4a) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) ... Previous atomic write of size 8 at 0x7fffb6bdc1a0 by thread T8 (mutexes: read M0): #0 _Py_atomic_store_ssize_relaxed /__w/jax/jax/cpython/./Include/cpython/pyatomic_gcc.h:513:3 (python3.14+0x2e22b9) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) #1 frozenset_hash /__w/jax/jax/cpython/Objects/setobject.c:801:5 (python3.14+0x2e22b9) #2 PyObject_Hash /__w/jax/jax/cpython/Objects/object.c (python3.14+0x2a6c56) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) #3 tuple_hash /__w/jax/jax/cpython/Objects/tupleobject.c:321:27 (python3.14+0x2f38bf) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) #4 PyObject_Hash /__w/jax/jax/cpython/Objects/object.c (python3.14+0x2a6c56) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) #5 builtin_hash /__w/jax/jax/cpython/Python/bltinmodule.c:1736:9 (python3.14+0x3f0d15) (BuildId: 48c7ba326d9f22d081e76424a9d52fc8476e98f5) ``` Probably missing atomic read here: https://github.com/python/cpython/blob/f2daa96c81a45b26bdcf3d5c3887cec02137974e/Objects/setobject.c#L2144 CPython version: Python 3.14.0a6+ experimental free-threading build (heads/main:8680400, Apr 6 2025, 05:24:33) [Clang 18.1.3 (1ubuntu1)] cc @kumaraditya303 ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132215 * gh-132447 <!-- /gh-linked-prs -->
ed99e28d5b5613f7c13691fd854195719d7bff1f
fd1b98dd1df14c8e4138d779166635c98926197b
python/cpython
python__cpython-132212
# Abort when using a tuple subclass instance as the `bases` parameter for `type` # Crash report ### What happened? The interpreter will abort when a new type is created using an instance of a subclass of `tuple` as the `bases` parameter due to a `PyTuple_CheckExact(bases)` assertion: ```python class weird_tuple(tuple): pass c = type("c", weird_tuple((str,)), {}) python: Objects/typeobject.c:500: set_tp_bases: Assertion `PyTuple_CheckExact(bases)' failed. Aborted (core dumped) ``` Found using [fusil](https://github.com/devdanzin/fusil) by @vstinner. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.14.0a6+ (heads/main:04bc681e7cf, Apr 4 2025, 12:38:19) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-132212 * gh-132548 <!-- /gh-linked-prs -->
b6c552f9e614bab4acf21584baed997f57e74114
e10fe81cc6ae0979938eb3925139d56a74c620e3
python/cpython
python__cpython-132175
# Incorrect function name in error message of `_interpreters.run_string` While working on https://github.com/python/cpython/pull/132173 I've noticed that this error message mentions the wrong function: ```python >>> import _interpreters >>> _interpreters.create() 1 >>> _interpreters.run_string(1, '') Traceback (most recent call last): File "<python-input-2>", line 1, in <module> _interpreters.run_string(1, '') ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ ValueError: _interpreters.exec(): bad script text (too short) ``` It should be: ```python >>> import _interpreters >>> _interpreters.create() 1 >>> _interpreters.run_string(1, '') Traceback (most recent call last): File "<python-input-4>", line 1, in <module> _interpreters.run_string(1, '') ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ ValueError: _interpreters.run_string(): bad script text (too short) ``` I have a PR ready. <!-- gh-linked-prs --> ### Linked PRs * gh-132175 * gh-132209 <!-- /gh-linked-prs -->
f2daa96c81a45b26bdcf3d5c3887cec02137974e
af8d1b95377917036aaedf18b9cc047d8877259c
python/cpython
python__cpython-132173
# Assertion failure calling `_interpreters.run_string` with a string subclass instance # Crash report ### What happened? It's possible to make the interpreter abort by calling `_interpreters.run_string` with an instance of a subclass of `str` as the `script` argument: ```python import _interpreters class weird_str(str): pass _interpreters.create() _interpreters.run_string(1, weird_str('1')) python: ./Modules/_interpretersmodule.c:333: get_code_str: Assertion `PyUnicode_CheckExact(arg) && (check_code_str((PyUnicodeObject *)arg) == NULL)' failed. Aborted (core dumped) ``` This happens because, after a check that `arg` is a `str` or subclass, there's an assertion that `arg` is exactly an instance of `str`: ```c if (PyUnicode_Check(arg)) { assert(PyUnicode_CheckExact(arg) && (check_code_str((PyUnicodeObject *)arg) == NULL)); ``` Found using [fusil](https://github.com/devdanzin/fusil) by @vstinner. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.14.0a6+ (heads/main:04bc681e7cf, Apr 4 2025, 12:38:19) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-132173 * gh-132219 <!-- /gh-linked-prs -->
398071871066548954f4c51e8250d13b7c9659e0
895d983b5c9716aaaab34d14d278084b9b6730d8
python/cpython
python__cpython-132169
# Add `__class_getitem__` support to `ctypes.py_object` # Feature or enhancement ### Proposal: [`ctypes.py_object`](https://docs.python.org/3/library/ctypes.html#ctypes.py_object) is [generic in typeshed](https://github.com/python/typeshed/blob/1c17cd429c2f91b0066547deb99c537af3e54d39/stdlib/ctypes/__init__.pyi#L253), but is not subscriptable at runtime. This can be troublesome for end users, since type checkers will prompt them to supply a generic type argument, but doing so will produce a `TypeError` at runtime: ```python >>> import ctypes >>> ctypes.py_object[int] Traceback (most recent call last): File "<python-input-1>", line 1, in <module> ctypes.py_object[int] ~~~~~~~~~~~~~~~~^^^^^ TypeError: type 'py_object' is not subscriptable ``` (albeit this is partially mitigated by deferred annotations in 3.14, but `TypeError` can still pop up if the annotations are ever evaluated) `py_object`'s typeshed stubs have been stable for a while, and it seems unlikely to be made non-generic in the future. Therefore I propose that `__class_getitem__` be added to `ctypes.py_object` so that it can be subscripted at runtime. ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: https://github.com/python/typeshed/pull/13760 <!-- gh-linked-prs --> ### Linked PRs * gh-132169 <!-- /gh-linked-prs -->
e2476398ee9911b6b0b80e3ca182647805fde81f
0788948dcb980c7648b29ca363390b696d7f188f
python/cpython
python__cpython-132164
# Tests for Py_Universalnewlinefgets Cover by tests Py_Universalnewlinefgets as mentioned at [TODO](https://github.com/python/cpython/blob/c0661df42ad20e488dbfa3e0fec22462833fc3d6/Lib/test/test_capi/test_file.py#L297) <!-- gh-linked-prs --> ### Linked PRs * gh-132164 <!-- /gh-linked-prs -->
d7365e60500bea91383010a4bf9e26ff3acdfaa1
06a26fda607fb1a5e108cf82a0458c8ebf97f5d2
python/cpython
python__cpython-132160
# Do not shadow user arguments in generated `__new__` by `@warnings.deprecated` # Bug report ### Bug description: Follow comment https://github.com/python/cpython/pull/132055#discussion_r2029062118 ```python from warnings import deprecated @deprecated("MyMeta will go away soon") class MyMeta(type): def __new__(mcs, name, bases, attrs, cls=None): return super().__new__(mcs, name, bases, attrs) class Foo(metaclass=MyMeta, cls='haha'): pass ``` Output: ```console $ python3 test.py Traceback (most recent call last): File "/Users/PanXuehai/Projects/cpython/test.py", line 10, in <module> class Foo(metaclass=MyMeta, cls='haha'): pass TypeError: MyMeta.__new__() got multiple values for argument 'cls' ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-132160 * gh-132163 <!-- /gh-linked-prs -->
7bb1e1a23634bae81bf76fdb34e9f9f7e59b3793
c0661df42ad20e488dbfa3e0fec22462833fc3d6
python/cpython
python__cpython-132248
# `test.test_sys.TestRemoteExec` fails with `AssertionError` # Bug report ### Bug description: The test case `test_sys` failed when I ran `rt.bat test_sys`. The unittest report is as follow ```cmd FAIL: test_remote_exec_raises_audit_event (test.test_sys.TestRemoteExec.test_remote_exec_raises_audit_event) Test remote exec raises an audit event ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\Administrator\Desktop\project\cpython\Lib\test\test_sys.py", line 2106, in test_remote_exec_raises_audit_event self.assertIn(b"Remote script executed successfully!", stdout) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: b'Remote script executed successfully!' not found in b'Target process running...\r\n' ---------------------------------------------------------------------- Ran 90 tests in 1.495s FAILED (failures=1, skipped=7) test test_sys failed == Tests result: FAILURE == ``` It seems that the problem is caused by an unfinished subprocess since it runs synchronizely. However, when I commented the first two assertion statements. ```python # self.assertIn(b"Remote script executed successfully!", stdout) # self.assertIn(b"Audit event: remote_debugger_script, arg: ", stdout) self.assertEqual(stderr, b"") ``` The `stderr` is printed out as follow ``` Traceback (most recent call last): File "C:\Users\Administrator\Desktop\project\cpython\Lib\test\test_sys.py", line 2108, in test_remote_exec_raises_audit_event self.assertEqual(stderr, b"") ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ AssertionError: b'Exception ignored in audit hook:\r\nTrace[295 chars]\r\n' != b'' ``` OS: Windows 10 22H2 ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-132248 <!-- /gh-linked-prs -->
d6078ed6d0cb8745460769bbb5dd2392c91c2f55
e294e161a86b325e634b001e1edafdb1cb7d40c4
python/cpython
python__cpython-132146
# `typing.Union` does not support attribute assignment post gh-105511 # Bug report ### Bug description: Before #105511, `typing.Union` is implemented in Python, and custom attributes can be assigned to a `Union` variable. - #105511 ```python ta = Union[int, str] ta.__some_attribute__ = (int, str) ``` However, after #105511, `typing.Union` is now implemented in C, and no attributes can be assigned to it. The `UnionType` does not allow subclassing; users cannot bypass this using subclassing. ```python $ ipython Python 3.14.0a6+ experimental free-threading build (heads/main:1755157207c, Apr 6 2025, 02:21:10) [Clang 17.0.0 (clang-1700.0.13.3)] Type 'copyright', 'credits' or 'license' for more information IPython 9.0.2 -- An enhanced Interactive Python. Type '?' for help. Tip: Use `object?` to see the help on `object`, `object??` to view it's source In [1]: import optree In [2]: optree.PyTree[int] /Users/PanXuehai/Projects/optree/env/lib/python3.14t/site-packages/IPython/core/interactiveshell.py:3111: SyntaxWarning: 'return' in a 'finally' block return result ╭────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────────────────────────╮ │ in <module>:1 │ │ │ │ /Users/PanXuehai/Projects/cpython/.pydev/lib/python3.14t/typing.py:398 in inner │ │ │ │ 395 │ │ @functools.wraps(func) │ │ 396 │ │ def inner(*args, **kwds): │ │ 397 │ │ │ try: │ │ ❱ 398 │ │ │ │ return _caches[func](*args, **kwds) │ │ 399 │ │ │ except TypeError: │ │ 400 │ │ │ │ pass # All real errors (not unhashable args) are raised below. │ │ 401 │ │ │ return func(*args, **kwds) │ │ │ │ /Users/PanXuehai/Projects/optree/optree/typing.py:254 in __class_getitem__ │ │ │ │ 251 │ │ │ Deque[recurse_ref], # type: ignore[valid-type] │ │ 252 │ │ │ CustomTreeNode[recurse_ref], # type: ignore[valid-type] │ │ 253 │ │ ] │ │ ❱ 254 │ │ pytree_alias.__pytree_args__ = item # type: ignore[attr-defined] │ │ 255 │ │ │ │ 256 │ │ # pylint: disable-next=no-member │ │ 257 │ │ original_copy_with = pytree_alias.copy_with # type: ignore[attr-defined] │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ AttributeError: 'typing.Union' object has no attribute '__pytree_args__' and no __dict__ for setting new attributes In [3]: class Foo(type(int | str)): ...: pass ...: ╭────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────────────────────────╮ │ in <module>:1 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ TypeError: type 'typing.Union' is not an acceptable base type ``` Repro: ```bash ./python -m pip install -v optree ./python -c 'import optree; optree.PyTree[int]' ``` Source: https://github.com/metaopt/optree/blob/v0.15.0/optree/typing.py#L246-L254 cc @JelleZijlstra ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-132146 * gh-132157 <!-- /gh-linked-prs -->
dbfc6a417a5db237ff16a8a75f09c1bd5d5bd349
0dba59e6899cd0b1717e3c1dc6110b18c91b0f8f
python/cpython
python__cpython-132135
# Add .cache directory to .gitignore # Bug report ### Bug description: For now, there are many people use vscode + clangd to developer cpython. But the clangd will generate a `.cache` directory under the base directory and the behavior could not be customized. So I think maybe we can add the `.cache` to the `.gitignore` FYI https://github.com/clangd/clangd/issues/946 ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132135 * gh-132144 * gh-132145 <!-- /gh-linked-prs -->
86804003ed70acbf8a2531c6784895d750c50456
85bc489b649fe261f9625163c684a69a470b3dc1
python/cpython
python__cpython-134085
# Ensure that `multiprocessing.util.get_temp_dir()` can be used to create socket files with limited path length # Bug report ### Bug description: I must admit that this issue only happens in very specific conditions, namely when using the multiprocessing lib on a system where the temp folder is set to a long path by the user. One could argue this is a user error, but bear with me a second. The problem is in `multiprocessing.util.get_temp_dir` ```python def get_temp_dir(): # get name of a temp directory which will be automatically cleaned up tempdir = process.current_process()._config.get('tempdir') # This could be set to an arbitrary long path by users if tempdir is None: import shutil, tempfile tempdir = tempfile.mkdtemp(prefix='pymp-') info('created temp directory %s', tempdir) # keep a strong reference to shutil.rmtree(), since the finalizer # can be called late during Python shutdown Finalize(None, _remove_temp_dir, args=(shutil.rmtree, tempdir), exitpriority=-100) process.current_process()._config['tempdir'] = tempdir return tempdir ``` This function is used in `multiprocessing.connect.arbitrary_address` ```python def arbitrary_address(family): ''' Return an arbitrary free address for the given family ''' if family == 'AF_INET': return ('localhost', 0) elif family == 'AF_UNIX': return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) elif family == 'AF_PIPE': return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % (os.getpid(), next(_mmap_counter)), dir="") else: raise ValueError('unrecognized family') ``` Where this is problematic is that arbitrary_address is used in `multiprocessing.forkserver.Forkserver.ensure_running` which uses the address provided by arbitrary_address to create and bind to a socket ```python with socket.socket(socket.AF_UNIX) as listener: address = connection.arbitrary_address('AF_UNIX') listener.bind(address) if not util.is_abstract_socket_namespace(address): os.chmod(address, 0o600) listener.listen() ``` Since UNIX sockets path have a limited character count between 92 and 108 [1], it would make sense for the std lib to have safe guards against generating paths that are too long to begin with. Sure, users can use work arounds such as setting TMP_DIR="/tmp" [2] but this requires each and every user of the multiprocessing library to be aware of such limitations. I propose we fix the problem once and for all at the source, by checking the size of the path created by `tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir())` and should it be greater or equal to the max length supported by the platform, reverting to what `get_temp_dir()` does when `tempdir=None` [1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_un.h.html#tag_13_67_04 [2] https://patchwork.ozlabs.org/project/qemu-devel/patch/20220722182508.89761-2-peter@pjd.dev/#2938322 ### CPython versions tested on: 3.11 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-134085 * gh-134447 * gh-134448 <!-- /gh-linked-prs -->
1a07a01014bde23acd2684916ef38dc0cd73c2de
e1f891414b2329414a6160ed246f5f869a218bfd
python/cpython
python__cpython-132122
# pygettext: Always escape non-printable characters regardless of the `--escape` option # Feature or enhancement ### Proposal: For context: https://github.com/python/cpython/pull/131902#discussion_r2022611826 > [...] but I think that non-printable characters should always be escaped. The POT file should be human readable. Currently, we only escape non-printable ASCII chars, other non-printable characters are not escaped when the `--escape` is not passed. ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-132122 <!-- /gh-linked-prs -->
a693eaa7104f3d2e42a3a1e0347775a3d2757b05
7bb1e1a23634bae81bf76fdb34e9f9f7e59b3793
python/cpython
python__cpython-132446
# dataclasses.InitVar undocumented # Documentation dataclasses.InitVar is mentioned in https://docs.python.org/3.14/library/dataclasses.html#init-only-variables but not itself documented or linkable to <!-- gh-linked-prs --> ### Linked PRs * gh-132446 * gh-132483 <!-- /gh-linked-prs -->
281fc338fdf57ef119e213bf1b2c772261c359c1
1d97488c957f4595f8c3ea42e24c1995b23e39d4
python/cpython
python__cpython-132107
# Allow logging.handlers.QueueListener to be used as a context manager # Feature or enhancement ### Proposal: This is a simple change that would allow: ```python with QueueListener(queue, handler1) as listener: # the listener has started ... # the listener has stopped ``` It's a welcomed alternative to needing to call start/stop manually. ### Has this already been discussed elsewhere? I have already discussed this feature proposal on Discourse ### Links to previous discussion of this feature: https://discuss.python.org/t/allow-logging-handlers-queuelistener-to-be-used-as-a-context-manager/87124 <!-- gh-linked-prs --> ### Linked PRs * gh-132107 * gh-132444 * gh-132471 <!-- /gh-linked-prs -->
517e96b9ed9f2b808ce499d01f6b5db5635218e3
ad3bbe8fbcc9045c436b0c5e49b1aec018c59c2d
python/cpython
python__cpython-132118
# Inconsistency in handling Bluetooth addresses # Bug report 1. The format accepted by BTPROTO_HCI protocol is incorrectly documented. * it accepts a bytes object `bdaddr`, not a tuple. * `bdaddr` is a bytes object, not a string. 2. Some protocols accept `bdaddr` as a string, others accept it as a bytes object. `getsockname()` returns it as a string or a bytes object, and this is not always consistent with the accepted type. 3. `getsockname()` not always return an address in the acceptable format. It returns `device_id` when the acceptable format is a tuple `(device_id,)`, can return a string when the acceptable format is a bytes object. First problem should be solved by updating the documentation. For second problem, I propose to make both string and bytes be accepted as a Bluetooth address. Also, if a 1-tuple is accepted, then its element should be accepted, and if `bdaddr` is accepted, then a 1-tuple `(bdaddr,)` should be accepted. The third problem cannot be resolved in backward compatible way. The solution for the second problem formally fixes incompatibility between input and output formats, but formats are still inconsistent between protocols. And after adding support for `hci_channel` (see #70145), the type of the `getsockname()` result will depend on the `hci_channel` value. <!-- gh-linked-prs --> ### Linked PRs * gh-132118 * gh-132482 * gh-132486 * gh-132497 * gh-132525 <!-- /gh-linked-prs -->
1d97488c957f4595f8c3ea42e24c1995b23e39d4
c7f6535e4a3b447fbd67bf98eea82fd243e780be
python/cpython
python__cpython-131605
# UBSan: runtime undefined behaviours when using `-fsanitize=undefined -fno-sanitize-recover` # Bug report ### Bug description: We finally managed to fix gh-111178, but this is assuming that Python is compiled with `-fsanitize=function`. When compiling Python as follows (with clang 18.1.8): ```sh ./configure \ -q --with-pydebug \ --with-undefined-behavior-sanitizer \ CC=clang LD=clang \ CFLAGS="-fsanitize=undefined -fno-sanitize-recover" \ LDFLAGS="-fsanitize=undefined -fno-sanitize-recover" ``` we still have some tests failing: - https://github.com/python/cpython/pull/131605#issuecomment-2779318764 - https://github.com/python/cpython/pull/131605#issuecomment-2779323572 (cc @vstinner as the original author to gh-131674). Others related to the second item above: <details> ``` 0:00:56 load avg: 32.43 [448/486/3] test_xxtestfuzz worker non-zero exit code (Exit code 1) -- running (2): test.test_multiprocessing_spawn.test_processes (54.6 sec), test.test_multiprocessing_forkserver.test_processes (55.2 sec) Modules/expat/xmlparse.c:6779:5: runtime error: call to function expat_default_handler through pointer to incorrect function type 'void (*)(void *, const char *, int)' /$HOME/lib/python/cpython/./Modules/_elementtree.c:3212: note: expat_default_handler defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Modules/expat/xmlparse.c:6779:5 ``` </details> Others on fautlhandler, but I'm not sure whether this is the UB that is being reported or something else: <details> ```txt #0 0x7ff4cf25f76b in raise (/lib64/libpthread.so.0+0x1676b) (BuildId: 938e42b7e407d175ee3ef9a89c038168101d330c) #1 0x55776b2dc6f2 in faulthandler_raise_sigsegv /$HOME/lib/python/cpython/./Modules/faulthandler.c:1053:5 #2 0x55776b2dc6f2 in faulthandler_sigsegv /$HOME/lib/python/cpython/./Modules/faulthandler.c:1069:9 #3 0x55776b01e13d in cfunction_call /$HOME/lib/python/cpython/Objects/methodobject.c:562:18 #4 0x55776af71824 in _PyObject_MakeTpCall /$HOME/lib/python/cpython/Objects/call.c:242:18 #5 0x55776b1a4db0 in _PyEval_EvalFrameDefault /$HOME/lib/python/cpython/Python/generated_cases.c.h:1434:35 #6 0x55776b174755 in _PyEval_Vector /$HOME/lib/python/cpython/Python/ceval.c:1902:12 #7 0x55776b1744d9 in PyEval_EvalCode /$HOME/lib/python/cpython/Python/ceval.c:829:21 #8 0x55776b2956b3 in run_mod /$HOME/lib/python/cpython/Python/pythonrun.c:1436:19 #9 0x55776b292931 in _PyRun_StringFlagsWithName /$HOME/lib/python/cpython/Python/pythonrun.c:1259:15 #10 0x55776b292931 in _PyRun_SimpleStringFlagsWithName /$HOME/lib/python/cpython/Python/pythonrun.c:578:15 #11 0x55776b2d70e5 in pymain_run_command /$HOME/lib/python/cpython/Modules/main.c:255:11 #12 0x55776b2d70e5 in pymain_run_python /$HOME/lib/python/cpython/Modules/main.c:671:21 #13 0x55776b2d70e5 in Py_RunMain /$HOME/lib/python/cpython/Modules/main.c:761:5 #14 0x55776b2d7775 in pymain_main /$HOME/lib/python/cpython/Modules/main.c:791:12 #15 0x55776b2d7802 in Py_BytesMain /$HOME/lib/python/cpython/Modules/main.c:815:12 #16 0x7ff4cf03624c in __libc_start_main (/lib64/libc.so.6+0x3524c) (BuildId: 74f77bf013a66413c77197c121955e029c32d259) #17 0x55776ae8dd49 in _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:120 UndefinedBehaviorSanitizer can not provide additional info. SUMMARY: UndefinedBehaviorSanitizer: SEGV (/lib64/libpthread.so.0+0x1676b) (BuildId: 938e42b7e407d175ee3ef9a89c038168101d330c) in raise ==9369==ABORTING ``` </details> Finally, `test_regrtest` also fails but the test suite just hangs after crashing (but the UB seems to happen in a test related to XML so it's probably the same thing): <details> ``` 0:01:16 load avg: 26.11 [485/486/5] test_regrtest failed (1 failure) (38.8 sec) -- running (1): test_socket (35.7 sec) test test_regrtest failed -- Traceback (most recent call last): File "/$HOME/lib/python/cpython/Lib/test/test_regrtest.py", line 2289, in test_xml output = self.run_tests(testname, "--junit-xml", filename, exitcode=EXITCODE_BAD_TEST) File "/$HOME/lib/python/cpython/Lib/test/test_regrtest.py", line 927, in run_tests return self.run_python(cmdargs, **kw) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ File "/$HOME/lib/python/cpython/Lib/test/test_regrtest.py", line 777, in run_python proc = self.run_command(args, **kw) File "/$HOME/lib/python/cpython/Lib/test/test_regrtest.py", line 768, in run_command self.fail(msg) ~~~~~~~~~^^^^^ AssertionError: Command ['/$HOME/lib/python/cpython/python', '-X', 'faulthandler', '-I', '-m', 'test', '--testdir=/tmp/test_python_3mwd8cdm/tmpsfkk6fdz', 'test_regrtest_noop51', '--junit-xml', '@test_12395_tmpæ'] failed with exit code 1, but exit code 2 expected! stdout: --- Using random seed: 777580575 0:00:00 load avg: 26.11 Run 1 test sequentially in a single process 0:00:00 load avg: 26.11 [1/1] test_regrtest_noop51 test test_regrtest_noop51 failed -- Traceback (most recent call last): File "/tmp/test_python_3mwd8cdm/tmpsfkk6fdz/test_regrtest_noop51.py", line 8, in test_failed self.fail() ~~~~~~~~~^^ AssertionError: None Stdout: abc ef Stdout: abc ef Modules/expat/xmlparse.c:3162:9: runtime error: call to function expat_start_handler through pointer to incorrect function type 'void (*)(void *, const char *, const char **)' /$HOME/lib/python/cpython/./Modules/_elementtree.c:3259: note: expat_start_handler defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Modules/expat/xmlparse.c:3162:9 --- 0:01:46 load avg: 16.11 running (1): test_socket (1 min 5 sec) ^C ``` </details> ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131605 * gh-131665 * gh-132265 * gh-132398 * gh-132406 <!-- /gh-linked-prs -->
50e518e886e6dde5542a2372d5b04acbdda4fc7d
ea23c897cd25702e72a04e06664f6864f07a7c5d
python/cpython
python__cpython-132076
# Possible use of unitialized socked address # Bug report New Bluetooth tests added in #132023 fail on Fedora based platforms. It looks that the `hci_channel` member of the `sockaddr_hci` structure is not initialized. This may be a cause of the failure. On NetBSD and DragonFly `sockaddr_hci` is an alias of `sockaddr_bt` which contain other fields. This also may be an issue. If `sockaddr_hci` contains additional optional members, not initializing them with zeros also may cause troubles. It is safer to always initialize `sockaddr_hci` and all other `sockaddr_*` structures with zeroes. <!-- gh-linked-prs --> ### Linked PRs * gh-132076 * gh-132086 * gh-132087 <!-- /gh-linked-prs -->
345baa77ba2ce3b8ea8f2fad84754e5cc0b10938
255eb375a7cc3cb16698bebf42689e8bc783ed93
python/cpython
python__cpython-132195
# `singledispatch.register` fails for `lru_cache` decorated functions # Bug report Function decorated with both `@singledispatch.register` and `@lru_chache` fails with a cryptic error message. EDIT: In python 3.14a6. It works in python 3.9~3.13. ### Bug description: ```python import sys from functools import lru_cache, singledispatch, wraps from typing import Any, Callable def wrapped_lru_cache[T: Callable](maxsize: int = 1024) -> Callable[[T], T]: def decorator(func: T) -> T: @wraps(func) def wrapper(*args: Any, **kwargs: Any) -> Any: return lru_cache(maxsize=maxsize)(func)(*args, **kwargs) return wrapper # type: ignore return decorator if len(sys.argv) > 1 and sys.argv[1] == "--broken-in-py314": # does not work in python 3.14+ lru = lru_cache else: # workaround lru = wrapped_lru_cache @singledispatch def fun(x: str | tuple) -> int: raise TypeError(f"Input must be str or tuple not a {type(x)}") @fun.register @lru(maxsize=1024) # <- this def _(x: str) -> int: return len(x) @fun.register def _(x: tuple) -> int: sum = 0 for e in x: sum += fun(e) return sum if __name__ == "__main__": print(f"{fun("hello")=}") print(f"{fun(("hello", "sailor"))=}") ``` `python ./singledispatch_mwe.py`, but `python ./singledispatch_mwe.py --broken-in-py314` produces the following error: ``` Traceback (most recent call last): File ".../singledispatch_mwe.py", line 25, in <module> @fun.register ^^^^^^^^^^^^ File "~/.local/share/uv/python/cpython-3.14.0a6-macos-aarch64-none/lib/python3.14/functools.py", line 963, in register argname, cls = next(iter(get_type_hints(func, format=Format.FORWARDREF).items())) ``` In python 3.9~3.13 both of the above work. ### CPython versions tested on: 3.9~3.14 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-132195 <!-- /gh-linked-prs -->
4d3ad0467e5cb145b1f4bde4be5eb776946a4269
a1cd4ca7f46eafe61dc7f26692896a4a95c7e947
python/cpython
python__cpython-132129
# ProcessPoolExecutor swallows falsy Exceptions # Bug report ### Bug description: ```python import sys import concurrent.futures class MyException(Exception): def __bool__(self): return False def raiser(): raise MyException("foo") def main(): with concurrent.futures.ProcessPoolExecutor() as p: print(p.submit(raiser).result()) if __name__ == "__main__": sys.exit(main()) ``` This program prints `None`, but should fail and print a traceback ### CPython versions tested on: CPython main branch, 3.14, 3.13, 3.12, 3.11, 3.10, 3.9 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132129 * gh-132275 <!-- /gh-linked-prs -->
933c6653cba235b3af2250bb19713694b560c367
c5e856a5dc8eed4813ecb8fbf4120411af9a6130
python/cpython
python__cpython-132056
# Add `application/yaml` to `mimetypes` ### 1. Summary It would be nice if Python will associate popular configuration extensions `.yaml` and `.yml` with the `application/yaml` media type. ### 2. Behavior #### 2.1. Current ```python >>> import mimetypes >>> mimetypes.guess_file_type("KiraGoddess.yaml") (None, None) >>> mimetypes.guess_file_type("KiraGoddess.yml") (None, None) ``` #### 2.2. Desired ```python >>> import mimetypes >>> mimetypes.guess_file_type("KiraGoddess.yaml") ('application/yaml', None) >>> mimetypes.guess_file_type("KiraGoddess.yml") ('application/yaml', None) ``` ### 3. Specifications Comments in the `mimetypes` Python module: <https://github.com/python/cpython/blob/ef172521a9e9dfadebe57d590bfb53a0e9ac3a0b/Lib/mimetypes.py#L447-L449> [**RFC 9512 Abstract**](https://www.rfc-editor.org/rfc/rfc9512.html#abstract): > This document registers the `application/yaml` media type and the `+yaml` structured syntax suffix with IANA. [**RFC 9512 “Filename Extension” section**](https://www.rfc-editor.org/rfc/rfc9512.html#name-filename-extension): > The "yaml" filename extension is the preferred one; it is the most popular and widely used on the web. The "yml" filename extension is still used. The simultaneous usage of two filename extensions in the same context might cause interoperability issues (e.g., when both a "config.yaml" and a "config.yml" are present). [**IANA specification for `application/yaml`**](https://www.iana.org/assignments/media-types/application/yaml). ### 4. Has this already been discussed elsewhere? Issue authors in this issue tracker write: > This is a minor feature, which does not need previous discussion elsewhere Thanks. <!-- gh-linked-prs --> ### Linked PRs * gh-132056 <!-- /gh-linked-prs -->
132b6bc98f47a4d897dead8635b5a50a0baee485
fee808936fd04e850a62c9610498bbb2360efd31
python/cpython
python__cpython-132039
# test_perf_profiler test failure if installed perf version string contains commit hash # Bug report ### Bug description: In some installations, the installed `perf` version string may contain a commit hash, for example: ```sh >perf --version perf version 6.12.9.g242e6068fd5c ``` this causes the `test_perf_profiler` to fail with: ``` ValueError: invalid literal for int() with base 10: 'g242e6068fd5c' ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132039 * gh-132058 <!-- /gh-linked-prs -->
b6c92ec419cfa1e4483b072996bab403c9970a5d
5518c2ae09cd8f135981f362dabd000d44d26cac
python/cpython
python__cpython-132027
# _MIPS_SIM comparison may contain undefined identifiers for _ABI # Bug report ### Bug description: ```c #include <Python.h> ``` When built on a MIPS architecture, `_MIPS_SIM` is used to determine [architecture specifics](https://wiki.debian.org/ArchitectureSpecificsMemo#Summary). The value is expected to match either `_ABIO32`, `_ABIN32` or `_ABI64`. In `gcc` [config/mips/mips.h](https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/mips/mips.h;h=616a275b918c34caf87f333f40e00866504156d7;hb=04696df09633baf97cdbbdd6e9929b9d472161d3#l560) these values are defined as compiler `builtin_define` inside of a switch/case. That means, mips64el and mips64 architectures know about `_ABI64` but don't know about `_ABIO32` and `_ABIN32`. In turn, when CPython tries to use them in comparison, they may be undefined identifiers. In default compiler behavior, the undefined identifier will be evaluated as zero, and it will not match `_MIPS_SIM`. However, the issues pop up when `-Wundef` (or, even worse, `-Werror=undef`) compiler flag is enabled. Then suddenly it's visible as a warning or error: ```text In file included from /usr/include/python3.13/Python.h:14, from example.c:1: /usr/include/python3.13/pyconfig.h:59:20: error: "_ABIO32" is not defined, evaluates to 0 [-Werror=undef] 59 | # if _MIPS_SIM == _ABIO32 | ^~~~~~~ /usr/include/python3.13/pyconfig.h:61:22: error: "_ABIN32" is not defined, evaluates to 0 [-Werror=undef] 61 | # elif _MIPS_SIM == _ABIN32 | ^~~~~~~ ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132027 * gh-133092 <!-- /gh-linked-prs -->
6985e2e6dea67630cf13fc02b7ca727af383207b
20be6ba61ac8a0a5d6242701c4186579cfa653f0
python/cpython
python__cpython-132048
# Inconsistency in json.JSONEncoder Description Regarding skipkeys Behavior > If skipkeys is false (the default), a [TypeError](https://docs.python.org/3.13/library/exceptions.html#TypeError) will be raised when trying to encode keys that are not [str](https://docs.python.org/3.13/library/stdtypes.html#str), [int](https://docs.python.org/3.13/library/functions.html#int), [float](https://docs.python.org/3.13/library/functions.html#float) or None. If skipkeys is true, such items are simply skipped. However, boolean values (True and False) can be used as dictionary keys without raising a TypeError. I think this is a mistake. ```python json.JSONEncoder(skipkeys=False).encode({True:1}) ``` <!-- gh-linked-prs --> ### Linked PRs * gh-132048 * gh-132255 * gh-132256 <!-- /gh-linked-prs -->
403886c28ddb350bbcaea478f8d754ed14e10337
f7305a06c7a322d23b39ad9d16af814d467624c6
python/cpython
python__cpython-132918
# Error traceback when interrupting+terminating python # Bug report ### Bug description: How to reproduce: - start python3 - interrupt with ^Z - resume with `fg` - immediately press ^D (EOF) ```python $ python3 >>> ^Z Stopped $ fg ^D Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/lib/python3.13/_pyrepl/__main__.py", line 6, in <module> __pyrepl_interactive_console() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/lib/python3.13/_pyrepl/main.py", line 59, in interactive_console run_multiline_interactive_console(console) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "/usr/lib/python3.13/_pyrepl/simple_interact.py", line 142, in run_multiline_interactive_console statement = multiline_input(more_lines, ps1, ps2) File "/usr/lib/python3.13/_pyrepl/readline.py", line 389, in multiline_input return reader.readline() ~~~~~~~~~~~~~~~^^ File "/usr/lib/python3.13/_pyrepl/reader.py", line 803, in readline self.handle1() ~~~~~~~~~~~~^^ File "/usr/lib/python3.13/_pyrepl/reader.py", line 759, in handle1 event = self.console.get_event(block=False) File "/usr/lib/python3.13/_pyrepl/unix_console.py", line 406, in get_event self.push_char(self.__read(1)) ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/usr/lib/python3.13/_pyrepl/unix_console.py", line 388, in push_char self.event_queue.push(char) ~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "/usr/lib/python3.13/_pyrepl/unix_eventqueue.py", line 120, in push ord_char = char if isinstance(char, int) else ord(char) ~~~^^^^^^ TypeError: ord() expected a character, but string of length 0 found $ ``` Also + likely related: resuming Python doesn't restore the `>>>` prompt (nor command-line editing) until I press Enter, presumably due to the interactive interpreter not listening to SIGCONT. ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132918 * gh-133470 <!-- /gh-linked-prs -->
e4561da886717ddd01ab0970452a14a1531e874d
d48616e08cbf069847026a2ee35017ad5cbe12a8
python/cpython
python__cpython-132014
# TSAN race in frozenset_hash # Bug report ### Bug description: Frozenset's hash has code to cache the hash computation that is not thread-safe under free-threading: https://github.com/python/cpython/blob/b0f77c4d250789fd1deaab4912919e2e6b89e583/Objects/setobject.c#L796 TSAN report from JAX test suite under Python 3.14: ``` WARNING: ThreadSanitizer: data race (pid=145260) Read of size 8 at 0x7fffb70ee4a0 by thread T6 (mutexes: read M0): #0 frozenset_hash /__w/jax/jax/cpython/Objects/setobject.c:796:13 (python3.14+0x2e1d93) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390) #1 PyObject_Hash /__w/jax/jax/cpython/Objects/object.c (python3.14+0x2a6876) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390) #2 tuple_hash /__w/jax/jax/cpython/Objects/tupleobject.c:321:27 (python3.14+0x2f34bf) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390) #3 PyObject_Hash /__w/jax/jax/cpython/Objects/object.c (python3.14+0x2a6876) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390) #4 builtin_hash /__w/jax/jax/cpython/Python/bltinmodule.c:1736:9 (python3.14+0x3f0915) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390) ... Previous write of size 8 at 0x7fffb70ee4a0 by thread T1 (mutexes: read M0): #0 frozenset_hash /__w/jax/jax/cpython/Objects/setobject.c:801:14 (python3.14+0x2e1ec3) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390) #1 PyObject_Hash /__w/jax/jax/cpython/Objects/object.c (python3.14+0x2a6876) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390) #2 tuple_hash /__w/jax/jax/cpython/Objects/tupleobject.c:321:27 (python3.14+0x2f34bf) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390) #3 PyObject_Hash /__w/jax/jax/cpython/Objects/object.c (python3.14+0x2a6876) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390) #4 builtin_hash /__w/jax/jax/cpython/Python/bltinmodule.c:1736:9 (python3.14+0x3f0915) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390) ... ``` ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132014 <!-- /gh-linked-prs -->
76f6b5e64a8b6ea5a88606f3665cd9f52c2c2798
b0f77c4d250789fd1deaab4912919e2e6b89e583
python/cpython
python__cpython-132018
# Failed assertion in `_PyEval_EvalFrameDefault`: `self_o != NULL` # Crash report ### What happened? It's possible to make the interpreter exit with a failed assertion by running the following code: ```python import difflib obj = difflib.HtmlDiff(None, None, None, None,) try: for x in range(3): obj._split_line([], None, None) except: pass obj._split_line(list, None, None) ``` Backtrace: ```gdb python: Python/generated_cases.c.h:3345: _PyEval_EvalFrameDefault: Assertion `self_o != NULL' failed. Program received signal SIGABRT, Aborted. __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:44 44 ./nptl/pthread_kill.c: No such file or directory. (gdb) bt #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=140737350580032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3 0x00007ffff7ce0476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4 0x00007ffff7cc67f3 in __GI_abort () at ./stdlib/abort.c:79 #5 0x00007ffff7cc671b in __assert_fail_base (fmt=0x7ffff7e7b130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555555a43bc6 "self_o != NULL", file=0x555555a43993 "Python/generated_cases.c.h", line=3345, function=<optimized out>) at ./assert/assert.c:94 #6 0x00007ffff7cd7e96 in __GI___assert_fail (assertion=assertion@entry=0x555555a43bc6 "self_o != NULL", file=file@entry=0x555555a43993 "Python/generated_cases.c.h", line=line@entry=3345, function=function@entry=0x555555a44980 <__PRETTY_FUNCTION__.81> "_PyEval_EvalFrameDefault") at ./assert/assert.c:103 #7 0x0000555555837189 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555c6b558 <_PyRuntime+330424>, frame=0x7ffff7fb00a0, frame@entry=0x7ffff7fb0020, throwflag=throwflag@entry=0) at Python/generated_cases.c.h:3345 #8 0x000055555585db58 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb0020, tstate=0x555555c6b558 <_PyRuntime+330424>) at ./Include/internal/pycore_ceval.h:119 #9 _PyEval_Vector (tstate=tstate@entry=0x555555c6b558 <_PyRuntime+330424>, func=func@entry=0x7ffff7a8db50, locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/difflib-abort-assertion/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/difflib-abort-assertion/source2.py', '__cached__': None, 'difflib': <module at remote 0x7ffff7acc110>, 'obj': <HtmlDiff(_charjunk=None, _linejunk=None, _tabsize=None, _wrapcolumn=None) at remote 0x7ffff7a7be40>, 'x': 2}, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:1908 #10 0x000055555585dc57 in PyEval_EvalCode (co=co@entry=<code at remote 0x7ffff7bce400>, globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/difflib-abort-assertion/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/difflib-abort-assertion/source2.py', '__cached__': None, 'difflib': <module at remote 0x7ffff7acc110>, 'obj': <HtmlDiff(_charjunk=None, _linejunk=None, _tabsize=None, _wrapcolumn=None) at remote 0x7ffff7a7be40>, 'x': 2}, locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/difflib-abort-assertion/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/difflib-abort-assertion/source2.py', '__cached__': None, 'difflib': <module at remote 0x7ffff7acc110>, 'obj': <HtmlDiff(_charjunk=None, _linejunk=None, _tabsize=None, _wrapcolumn=None) at remote 0x7ffff7a7be40>, 'x': 2}) at Python/ceval.c:836 #11 0x00005555558eb82e in run_eval_code_obj (tstate=tstate@entry=0x555555c6b558 <_PyRuntime+330424>, co=co@entry=0x7ffff7bce400, globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/difflib-abort-assertion/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/difflib-abort-assertion/source2.py', '__cached__': None, 'difflib': <module at remote 0x7ffff7acc110>, 'obj': <HtmlDiff(_charjunk=None, _linejunk=None, _tabsize=None, _wrapcolumn=None) at remote 0x7ffff7a7be40>, 'x': 2}, locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/difflib-abort-assertion/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/difflib-abort-assertion/source2.py', '__cached__': None, 'difflib': <module at remote 0x7ffff7acc110>, 'obj': <HtmlDiff(_charjunk=None, _linejunk=None, _tabsize=None, _wrapcolumn=None) at remote 0x7ffff7a7be40>, 'x': 2}) at Python/pythonrun.c:1365 ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.14.0a6+ (heads/main:3a8cefba0b6, Apr 1 2025, 21:31:55) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-132018 * gh-132161 <!-- /gh-linked-prs -->
c0661df42ad20e488dbfa3e0fec22462833fc3d6
42e3a8410b7dbc960b3b7c335f2bbb516c8caf6e
python/cpython
python__cpython-132003
# Segfault deallocating a `ContextVar` built with `str` subclass # Crash report ### What happened? Creating a `ContextVar` with an instance of a subclass of `str` leads to a segfault during its deallocation: ```python from _contextvars import ContextVar class weird_str(str): def __eq__(self, other): pass ContextVar(weird_str()) ``` Backtrace: ```gdb Program received signal SIGSEGV, Segmentation fault. contextvar_tp_clear (op=op@entry=<_contextvars.ContextVar at remote 0x7ffff7ac7150>) at Python/context.c:935 935 Py_CLEAR(self->var_name); (gdb) bt #0 contextvar_tp_clear (op=op@entry=<_contextvars.ContextVar at remote 0x7ffff7ac7150>) at Python/context.c:935 #1 0x000055555587e395 in contextvar_tp_dealloc (self=<_contextvars.ContextVar at remote 0x7ffff7ac7150>) at Python/context.c:958 #2 0x00005555556ffa08 in _Py_Dealloc (op=op@entry=<_contextvars.ContextVar at remote 0x7ffff7ac7150>) at Objects/object.c:3021 #3 0x000055555587e672 in Py_DECREF (op=<_contextvars.ContextVar at remote 0x7ffff7ac7150>, lineno=883, filename=0x555555a49efe "Python/context.c") at ./Include/refcount.h:416 #4 contextvar_new (name=<weird_str() at remote 0x7ffff7bc7260>, def=0x0) at Python/context.c:883 #5 0x000055555587e6fe in contextvar_tp_new (type=<optimized out>, args=<optimized out>, kwds=<optimized out>) at Python/context.c:928 #6 0x000055555574692f in type_call (self=<type at remote 0x555555bff380>, args=(<weird_str() at remote 0x7ffff7bc7260>,), kwds=0x0) at Objects/typeobject.c:2244 #7 0x000055555567b9a7 in _PyObject_MakeTpCall (tstate=tstate@entry=0x555555c69558 <_PyRuntime+330424>, callable=callable@entry=<type at remote 0x555555bff380>, args=args@entry=0x7fffffffd7c8, nargs=<optimized out>, keywords=keywords@entry=0x0) at Objects/call.c:242 #8 0x000055555567bdc8 in _PyObject_VectorcallTstate (tstate=0x555555c69558 <_PyRuntime+330424>, callable=<type at remote 0x555555bff380>, args=0x7fffffffd7c8, nargsf=<optimized out>, kwnames=0x0) at ./Include/internal/pycore_call.h:167 #9 0x000055555567bdf4 in PyObject_Vectorcall (callable=callable@entry=<type at remote 0x555555bff380>, args=args@entry=0x7fffffffd7c8, nargsf=<optimized out>, kwnames=kwnames@entry=0x0) at Objects/call.c:327 #10 0x000055555582f4c0 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555c69558 <_PyRuntime+330424>, frame=frame@entry=0x7ffff7fb0020, throwflag=throwflag@entry=0) at Python/generated_cases.c.h:1366 #11 0x000055555585cd69 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb0020, tstate=0x555555c69558 <_PyRuntime+330424>) at ./Include/internal/pycore_ceval.h:119 ``` Found using [fusil](https://github.com/devdanzin/fusil) by @vstinner. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux, Windows ### Output from running 'python -VV' on the command line: Python 3.14.0a6+ (heads/main:be2d2181e62, Mar 31 2025, 07:30:17) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-132003 * gh-132007 * gh-132008 <!-- /gh-linked-prs -->
ab2a3dda1d3b6668162a847bf5b6aca2855a3416
87d9983994e9a423e9e0050b1bbee52ebaf84367
python/cpython
python__cpython-132000
# The interpreter crashes when specializing bound method calls on unbound objects # Crash report ### What happened? The following code segfaults the interpreter: ```python import glob for x in range(3): str_globber = glob._StringGlobber(None, None) str_globber.selector(set()) try: str_globber.selector([True, True, False]) except: pass globber_base = glob._GlobberBase(0, 0, 0, 0) globber_base.selector(list) ``` (Edited by @ZeroIntensity) Smaller reproducer: ```py def call(part): part.pop() call(['a']) try: call(list) except TypeError: raise ``` Backtrace: ```gdb Program received signal SIGSEGV, Segmentation fault. _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555c6b558 <_PyRuntime+330424>, frame=0x7ffff7fb00a0, frame@entry=0x7ffff7fb0020, throwflag=throwflag@entry=0) at ./Include/object.h:270 270 return ob->ob_type; (gdb) bt #0 _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555c6b558 <_PyRuntime+330424>, frame=0x7ffff7fb00a0, frame@entry=0x7ffff7fb0020, throwflag=throwflag@entry=0) at ./Include/object.h:270 #1 0x000055555585db58 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb0020, tstate=0x555555c6b558 <_PyRuntime+330424>) at ./Include/internal/pycore_ceval.h:119 #2 _PyEval_Vector (tstate=tstate@entry=0x555555c6b558 <_PyRuntime+330424>, func=func@entry=0x7ffff7a91b50, locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', '__cached__': None, 'glob': <module at remote 0x7ffff7ad0170>, 'x': 2, 'str_globber': <_StringGlobber(sep=None, case_sensitive=None, case_pedantic=False, recursive=False) at remote 0x7ffff78ef630>, 'globber_base': <_GlobberBase(case_pedantic=0, case_sensitive=0, recursive=0, sep=0) at remote 0x7ffff7a7e6e0>}, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:1908 #3 0x000055555585dc57 in PyEval_EvalCode (co=co@entry=<code at remote 0x7ffff7b5db60>, globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', '__cached__': None, 'glob': <module at remote 0x7ffff7ad0170>, 'x': 2, 'str_globber': <_StringGlobber(sep=None, case_sensitive=None, case_pedantic=False, recursive=False) at remote 0x7ffff78ef630>, 'globber_base': <_GlobberBase(case_pedantic=0, case_sensitive=0, recursive=0, sep=0) at remote 0x7ffff7a7e6e0>}, locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', '__cached__': None, 'glob': <module at remote 0x7ffff7ad0170>, 'x': 2, 'str_globber': <_StringGlobber(sep=None, case_sensitive=None, case_pedantic=False, recursive=False) at remote 0x7ffff78ef630>, 'globber_base': <_GlobberBase(case_pedantic=0, case_sensitive=0, recursive=0, sep=0) at remote 0x7ffff7a7e6e0>}) at Python/ceval.c:836 #4 0x00005555558eb82e in run_eval_code_obj (tstate=tstate@entry=0x555555c6b558 <_PyRuntime+330424>, co=co@entry=0x7ffff7b5db60, globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', '__cached__': None, 'glob': <module at remote 0x7ffff7ad0170>, 'x': 2, 'str_globber': <_StringGlobber(sep=None, case_sensitive=None, case_pedantic=False, recursive=False) at remote 0x7ffff78ef630>, 'globber_base': <_GlobberBase(case_pedantic=0, case_sensitive=0, recursive=0, sep=0) at remote 0x7ffff7a7e6e0>}, locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', '__cached__': None, 'glob': <module at remote 0x7ffff7ad0170>, 'x': 2, 'str_globber': <_StringGlobber(sep=None, case_sensitive=None, case_pedantic=False, recursive=False) at remote 0x7ffff78ef630>, 'globber_base': <_GlobberBase(case_pedantic=0, case_sensitive=0, recursive=0, sep=0) at remote 0x7ffff7a7e6e0>}) at Python/pythonrun.c:1365 #5 0x00005555558ec92e in run_mod (mod=mod@entry=0x555555e0e230, filename=filename@entry='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', '__cached__': None, 'glob': <module at remote 0x7ffff7ad0170>, 'x': 2, 'str_globber': <_StringGlobber(sep=None, case_sensitive=None, case_pedantic=False, recursive=False) at remote 0x7ffff78ef630>, 'globber_base': <_GlobberBase(case_pedantic=0, case_sensitive=0, recursive=0, sep=0) at remote 0x7ffff7a7e6e0>}, locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', '__cached__': None, 'glob': <module at remote 0x7ffff7ad0170>, 'x': 2, 'str_globber': <_StringGlobber(sep=None, case_sensitive=None, case_pedantic=False, recursive=False) at remote 0x7ffff78ef630>, 'globber_base': <_GlobberBase(case_pedantic=0, case_sensitive=0, recursive=0, sep=0) at remote 0x7ffff7a7e6e0>}, flags=flags@entry=0x7fffffffdb68, arena=arena@entry=0x7ffff7ab3f40, interactive_src=0x0, generate_new_source=0) at Python/pythonrun.c:1436 #6 0x00005555558eccdb in pyrun_file (fp=fp@entry=0x555555df2410, filename=filename@entry='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', start=start@entry=257, globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', '__cached__': None, 'glob': <module at remote 0x7ffff7ad0170>, 'x': 2, 'str_globber': <_StringGlobber(sep=None, case_sensitive=None, case_pedantic=False, recursive=False) at remote 0x7ffff78ef630>, 'globber_base': <_GlobberBase(case_pedantic=0, case_sensitive=0, recursive=0, sep=0) at remote 0x7ffff7a7e6e0>}, locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', '__cached__': None, 'glob': <module at remote 0x7ffff7ad0170>, 'x': 2, 'str_globber': <_StringGlobber(sep=None, case_sensitive=None, case_pedantic=False, recursive=False) at remote 0x7ffff78ef630>, 'globber_base': <_GlobberBase(case_pedantic=0, case_sensitive=0, recursive=0, sep=0) at remote 0x7ffff7a7e6e0>}, closeit=closeit@entry=1, flags=0x7fffffffdb68) at Python/pythonrun.c:1293 #7 0x00005555558eeff1 in _PyRun_SimpleFileObject (fp=fp@entry=0x555555df2410, filename=filename@entry='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', closeit=closeit@entry=1, flags=flags@entry=0x7fffffffdb68) at Python/pythonrun.c:521 #8 0x00005555558ef2ba in _PyRun_AnyFileObject (fp=fp@entry=0x555555df2410, filename=filename@entry='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', closeit=closeit@entry=1, flags=flags@entry=0x7fffffffdb68) at Python/pythonrun.c:81 #9 0x000055555591ebd4 in pymain_run_file_obj (program_name=program_name@entry='/home/danzin/projects/cpython/python', filename=filename@entry='/home/fusil/runs/python-12/glob-cpu_load-invalid_mem_access-0x0000000000000008/source2.py', skip_source_first_line=0) at Modules/main.c:396 #10 0x000055555591ef72 in pymain_run_file (config=config@entry=0x555555c36688 <_PyRuntime+113640>) at Modules/main.c:415 #11 0x000055555592050d in pymain_run_python (exitcode=exitcode@entry=0x7fffffffdcf4) at Modules/main.c:680 #12 0x000055555592056e in Py_RunMain () at Modules/main.c:761 #13 0x00005555559205e5 in pymain_main (args=args@entry=0x7fffffffdd50) at Modules/main.c:791 #14 0x00005555559206a8 in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:815 #15 0x00005555555d7926 in main (argc=<optimized out>, argv=<optimized out>) at ./Programs/python.c:15 ``` Found using [fusil](https://github.com/devdanzin/fusil) by @vstinner. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.14.0a6+ (heads/main:3a8cefba0b6, Apr 1 2025, 21:31:55) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-132000 * gh-132262 <!-- /gh-linked-prs -->
ac3c439cdfee8452f2bcceacd67a1f4e423ac3cf
3eda1460359c7e6af4c5b125a63388635a3ed477
python/cpython
python__cpython-131991
# Compilation on Windows fails with assert in generated_cases.c.h # Bug report ### Bug description: Command line: `.\PCBuild\build.bat -p x64 -d -r` ``` python.c python.vcxproj -> D:\Sources\_pythonish\cpython\PCbuild\amd64\python_d.exe Assertion failed: WITHIN_STACK_BOUNDS(), file D:\Sources\_pythonish\cpython\Python\generated_cases.c.h, line 11092 D:\Sources\_pythonish\cpython\PCbuild\python.vcxproj(134,5): warning MSB3073: The command "setlocal D:\Sources\_pythonish\cpython\PCbuild\python.vcxproj(134,5): warning MSB3073: set PYTHONPATH=D:\Sources\_pythonish\cpython\Lib D:\Sources\_pythonish\cpython\PCbuild\python.vcxproj(134,5): warning MSB3073: "D:\Sources\_pythonish\cpython\PCbuild\amd64\python_d.exe" "D:\Sources\_pythonish\cpython\PC\validate_ucrtbase.py" ucrtbased" exited with code 3. Wrote D:\Sources\_pythonish\cpython\PCbuild\amd64\LICENSE.txt WinMain.c pythonw.vcxproj -> D:\Sources\_pythonish\cpython\PCbuild\amd64\pythonw_d.exe Build succeeded. D:\Sources\_pythonish\cpython\PCbuild\python.vcxproj(134,5): warning MSB3073: The command "setlocal D:\Sources\_pythonish\cpython\PCbuild\python.vcxproj(134,5): warning MSB3073: set PYTHONPATH=D:\Sources\_pythonish\cpython\Lib D:\Sources\_pythonish\cpython\PCbuild\python.vcxproj(134,5): warning MSB3073: "D:\Sources\_pythonish\cpython\PCbuild\amd64\python_d.exe" "D:\Sources\_pythonish\cpython\PC\validate_ucrtbase.py" ucrtbased" exited with code 3. 1 Warning(s) 0 Error(s) Time Elapsed 00:01:06.65 ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-131991 <!-- /gh-linked-prs -->
cd69d55f64087f74da816eaf20c34ddeabfdb2bb
c2ac662f284b7c3f0701173f2467bf1e18aad2e2
python/cpython
python__cpython-131975
# `ctypes.Pointer.get_contents` doesn't hold the object's lock for long enough # Bug report ### Bug description: As @kumaraditya303 [mentioned](https://github.com/python/cpython/pull/128490/files#r2022613718), `ctypes.Pointer.get_contents` has a thread safety bug that I missed when I originally fixed it. https://github.com/python/cpython/blob/3b3720f1a26ab34377542b48eb6a6565f78ff892/Modules/_ctypes/_ctypes.c#L5413-L5430 Dereferencing the pointer is locked, but it's unsafe to call `PyCData_FromBaseObj` without holding the lock, because the pointer might be invalidated concurrently. I suspect this kind of bug exists with other uses of `locked_deref` too. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131975 <!-- /gh-linked-prs -->
6e91d1f9aafc6e375092b8c14f6e30ebc74e4004
25275bda790e8a689092e83855d6d0574f26061b
python/cpython
python__cpython-132126
# Color in json.tool CLI # Feature or enhancement ### Proposal: apologies if this is not the right place to ask for enhancement requests. since python3.13 added support for colorization in repl, i was wondering if some basic colorization could be added for the python's cli json tool? jq[0] does this, the keys are bolded and have a different color from the values. if this gets implemented i think a lot of people will be happy to just use python and not have to install yet another library to fulfill their needs :-) [0] https://static1.howtogeekimages.com/wordpress/wp-content/uploads/2020/01/5-7.png ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-132126 <!-- /gh-linked-prs -->
71da68d5887b6c05890757d676b452ede3120617
e7c5f60efc149dda3d3592fa2001f4583b128512
python/cpython
python__cpython-131944
# Use the Python-specific `Py_DEBUG` macro rather than `_DEBUG` in Windows-related C code Follow the discussion at https://github.com/python/cpython/pull/131799#discussion_r2021223342. Currently, the Windows-related C code is mixed using the Python-specific `Py_DEBUG` macro and non-Python-specific `_DEBUG` macro. The documentation said `_DEBUG` implies `Py_DEBUG`. > ### [Py_DEBUG](https://docs.python.org/3/c-api/intro.html#c.Py_DEBUG) > > Compiling the interpreter with the `Py_DEBUG` macro defined produces what is generally meant by [a debug build of Python](https://docs.python.org/3/using/configure.html#debug-build). Py_DEBUG is enabled in the Unix build by adding [--with-pydebug](https://docs.python.org/3/using/configure.html#cmdoption-with-pydebug) to the `./configure` command. It is also implied by the presence of the not-Python-specific `_DEBUG` macro. When `Py_DEBUG` is enabled in the Unix build, compiler optimization is disabled. And it is guaranteed by the following code on Windows. https://github.com/python/cpython/blob/4940d96135a92b90bbc1dcc399f665817f956640/PC/pyconfig.h.in#L379-L381 All platform-non-specific code and Unix-specific code is using the Python-specific `Py_DEBUG` macro. It would be nice to use `Py_DEBUG` in Windows-related C code either. It could improve the code readability and maintainability. <!-- gh-linked-prs --> ### Linked PRs * gh-131944 <!-- /gh-linked-prs -->
f0f93ba5fa53ef5724250dd9f791d89abca04fa7
e15bbfafbcc9153fa0b05beb806984e288fdefe4
python/cpython
python__cpython-131972
# Update `Element.remove` exception message when an element is not found ### Proposal: In `xml.etree.ElementTree.Element.remove`, the exception message is `"list.remove(x): x not in list"`. It was suggested to change it to `"Element.remove(x): x not in list"` (https://github.com/python/cpython/pull/126124#discussion_r1941422029). Since we don't like changing exception messages in stable branches, we will only do it in main. Note that this change may not necessarily be trivial as the Python implementation also needs to be updated (out there, a list is used and using list.remove() would then use a different message). ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: https://github.com/python/cpython/pull/126124#discussion_r1941422029 <!-- gh-linked-prs --> ### Linked PRs * gh-131972 <!-- /gh-linked-prs -->
04bc681e7cf5b7effd99e676b7deceb27fb34434
df59226997e067adcfa1bc8d045b7cc1de08906c
python/cpython
python__cpython-131941
# 3.14 regression: `Union[int, str] is Union[int, str]` does not hold # Bug report ### Bug description: ### Python 3.13.2 ```pycon >>> from typing import Union >>> Union[int, str] is Union[int, str] True ``` ### Python 3.14.0a6 ```pycon >>> from typing import Union >>> Union[int, str] is Union[int, str] False ``` Is this change desired, is it documented? This breaks tests in https://github.com/python-attrs/cattrs/blob/d8f17b7e7e57006171027df4d647a6fe068b623e/tests/test_disambiguators.py#L211 ```python assert fn({"op": 0, "t": "MESSAGE_CREATE"}) is Union[F, G] ``` ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131941 <!-- /gh-linked-prs -->
7473c600a5890ffd87e8761c418bf3312ce7f38c
ac3a7bfeccb752a59d88861e45b454db360aa69d
python/cpython
python__cpython-131993
# Compilation emits multiple warnings in the finally block # Bug report This code produces two `SyntaxWarning`s in the new REPL: ```python >>> def some(): ... try: ... return 1 ... finally: ... return 2 ... <python-input-14>:5: SyntaxWarning: 'return' in a 'finally' block <python-input-14>:5: SyntaxWarning: 'return' in a 'finally' block ``` <img width="788" alt="Image" src="https://github.com/user-attachments/assets/e3e669e7-e431-4c61-b291-b8248ecdf1d5" /> But, in our old REPL it produces just one: <img width="788" alt="Image" src="https://github.com/user-attachments/assets/addd456d-95c7-4c9e-a01e-935feaeff6b1" /> Other `SyntaxWarning`s also do not show the same behavior in the new REPL. Example: <img width="788" alt="Image" src="https://github.com/user-attachments/assets/85dd4b50-2674-43d4-93fd-dafddb591310" /> So, looks like only PEP-765 is affected, only in the new REPL. CC @ambv @iritkatriel <!-- gh-linked-prs --> ### Linked PRs * gh-131993 * gh-132463 <!-- /gh-linked-prs -->
3d08c8ad20dfabd4864be139cd9c2eb5602ccdfe
d4e2cdc15bdfe84486b885eca885c44bc378fc41
python/cpython
python__cpython-132453
# Add `multiprocessing.Process.interrupt` # Feature or enhancement ### Proposal: We have `.terminate()` and `.kill()` but not `.interrupt()` for terminating `multiprocessing.Process`. I believe the latter could be a useful addition when we have a python subprocess that we want to terminate in a "normal" way: i.e. triggering finalizers, etc. This roughly demonstrates the difference when using one or the other (linux): ```python from signal import SIGINT from multiprocessing import Process from time import sleep def payload(): try: print("working") sleep(10) finally: print("a very important teardown") print("> kill or terminate") p = Process(target=payload) p.start() sleep(1) p.kill() # or terminate ``` output ``` > kill or terminate working ``` ```python class MyProcess(Process): def interrupt(self): return self._popen._send_signal(SIGINT) print("> interrupt") p = MyProcess(target=payload) p.start() sleep(1) p.interrupt() ``` output ``` > interrupt working a very important teardown Process MyProcess-2: Traceback (most recent call last): File "/usr/lib64/python3.13/multiprocessing/process.py", line 313, in _bootstrap self.run() ~~~~~~~~^^ File "/usr/lib64/python3.13/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "test.py", line 9, in payload sleep(10) ~~~~~^^^^ KeyboardInterrupt ``` Motivation for sending `SIGINT` to subprocesses in general: - it allows usual python patterns in the payload: we can now define `finally`, `with`, etc. and expect them to trigger normally - SIGINT is a very lean way to cancel heavy payloads. It is widely supported such that if you have non-pure-python stack you still have higher chances to exit gracefully - I also think it enables a better interaction with nested subprocesses: if a subprocess `S` manages some `Pool` or `concurrent` object, sending `SIGINT` to `S` will let nested subprocesses to exit gracefully as opposed to, for example, leaving orphans on linux. A pure nested `Process` will still leave orphans but you can write some code in the payload to work with this: ```python def payload(): try: p = MyProcess(target=inner) p.start() p.join() finally: p.interrupt() ``` Motivation for having `Process.interrupt()` in the standard library: - it is very easy to misuse `terminate` or `kill` without understanding the consequences or particularities of the two. `.interrupt` could become the default or recommended way to interrupt long-running tasks. Even without any payload-specific code, it prints error and python stack trace on termination which is a good starting point to write and debug multiprocessing code, thus, making it a friendlier environment - I feel like an average developer knows more about the difference between `.interrupt` and `.kill` than between `.terminate` and `.kill`. This is subjective, of course, but, discarding internal reasons to have both `.terminate` and `.kill`, I do not understand how `.interrupt` is not in this list. ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-132453 <!-- /gh-linked-prs -->
77605fa3bb4e380d5448665f70d73c8d3fcc2e75
862fd890361005598a6f4614ea0608c8447831c2
python/cpython
python__cpython-132030
# Move description of grouping options in format specification docs The form of format specifier is the following ``` [[fill]align][sign]["z"]["#"]["0"][width][grouping_option]["." precision][type] ``` Docs describe each option in the following order: 1. `align` and `fill`. 2. `sign`. 3. Option `z`. 4. Option `#`. 5. Option `,`. 6. Option `_`. 7. `width`, then option `0`. 8. `precision`. 9. `type`. As you can notice, options `,` and `_` are not present in format spec, because they are actually part of `grouping_option`. For whatever reason they are described before `width`, but most importantly, their descriptions never mention they are part of `grouping_option`. It can be super confusing for the first readthrough, as descriptions are out of order and written similar to standalone options `z` and `#`. I suggest the following changes: 1. Place descriptions of options `,` and `_` after the description of width. 2. Mention that they are part of `grouping_option`. 3. Maybe change BNF specification of `grouping_option` to `"," | "_"` to match their description order and order of addition to Python. Example change: > The *grouping_option* determines how digits in numbers are grouped. Its first option, `','`, signals... > > The other *grouping_option*, `'_'`, signals... Alternatively, these description can be placed in a table, similar for the list of string presentation types. > The *grouping_option* determines how digits in numbers are grouped. It can be one of the following: > > ==here goes the table== <!-- gh-linked-prs --> ### Linked PRs * gh-132030 * gh-132123 * gh-132203 * gh-132170 <!-- /gh-linked-prs -->
06a110f5227ba9d52f6205fde55924a14cab36ff
ac14d4a23f58c1f3e1909753aa17c1c302ea771d
python/cpython
python__cpython-132022
# CPython fails to compile when the internal `Py_STACKREF_DEBUG` macro is defined # Bug report ### Bug description: When the `Py_STACKREF_DEBUG` macro is defined here: https://github.com/python/cpython/blob/c432d0147bdf1a66604e7a3d6a71660ae79b5f45/Include/internal/pycore_structs.h#L57-L58 CPython fails to compile: ```sh ~ make -s In file included from ./Include/internal/pycore_dict.h:13, from Objects/call.c:4: ./Include/internal/pycore_stackref.h: In function ‘PyStackRef_XCLOSE’: ./Include/internal/pycore_stackref.h:154:21: error: too few arguments to function ‘_Py_stackref_close’ 154 | PyObject *obj = _Py_stackref_close(ref); | ^~~~~~~~~~~~~~~~~~ ./Include/internal/pycore_stackref.h:64:24: note: declared here 64 | PyAPI_FUNC(PyObject *) _Py_stackref_close(_PyStackRef ref, const char *filename, int linenumber); | ^~~~~~~~~~~~~~~~~~ make: *** [Makefile:3127: Objects/call.o] Error 1 make: *** Waiting for unfinished jobs.... ``` This error can probably be fixed by using `PyStackRef_CLOSE` instead of `_Py_stackref_close` but this reveals other errors which I'm not sure how to fix. cc @markshannon since you last worked on this area. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132022 <!-- /gh-linked-prs -->
275056a7fdcbe36aaac494b4183ae59943a338eb
b3e3cc054c2c7718c0ad7c4690f76716649a2588
python/cpython
python__cpython-131903
# Tail-calling interpreter `configure` failures on x86_64/aarch64 apple-darwin/clang # Bug report ### Bug description: The configure step fails. I've rerun it once but it still failed. - https://github.com/python/cpython/actions/runs/14138795354/job/39616444240#step:6:232 - https://github.com/python/cpython/actions/runs/14138795354/job/39616444585#step:6:231 ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-131903 <!-- /gh-linked-prs -->
39fa19a4ccb4c75d2421187e5b8d83c73b48ca4d
2c3e3fe54ce9aaa57b1e870c450d4cad4db4b208
python/cpython
python__cpython-131889
# intermittent ResourceWarning in test_ftplib Hi! The buildbot **PPC64LE Fedora Stable LTO 3.13** (tier-2) has failed when building commit 07d4c7e7dbdb4e676acab386d1a5bf8e4ac16898. You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/1492/builds/501 Summary of the results of the build (if available): ```python-traceback Traceback (most recent call last): File "/home/buildbot/buildarea/3.13.cstratak-fedora-stable-ppc64le.lto/build/Lib/test/test_ftplib.py", line 935, in tearDown self.server = None ResourceWarning: unclosed <ssl.SSLSocket fd=6, family=2, type=1, proto=0, laddr=('127.0.0.1', 39543), raddr=('127.0.0.1', 54764)> k Traceback (most recent call last): File "/home/buildbot/buildarea/3.13.cstratak-fedora-stable-ppc64le.lto/build/Lib/test/test_ftplib.py", line 935, in tearDown self.server = None ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=2, type=1, proto=0, laddr=('127.0.0.1', 43007), raddr=('127.0.0.1', 49844)> k ``` _Originally posted by @bedevere-bot in https://github.com/python/cpython/issues/131802#issuecomment-2764337842_ <!-- gh-linked-prs --> ### Linked PRs * gh-131889 * gh-132009 * gh-132010 <!-- /gh-linked-prs -->
b0f77c4d250789fd1deaab4912919e2e6b89e583
ab2a3dda1d3b6668162a847bf5b6aca2855a3416
python/cpython
python__cpython-132200
# `json.dump()` with `indent` and `skipkeys` can be formatted incorrectly # Bug report ### Bug description: ```python >>> import json >>> print(json.dumps({b"": 0}, indent=4, skipkeys=True)) { } ``` Related: #123183 ### CPython versions tested on: 3.13 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-132200 * gh-135060 * gh-135061 <!-- /gh-linked-prs -->
ec12559ebafca01ded22c9013de64abe535c838d
485b499610eefe362faf171f258b3a3588378ff1
python/cpython
python__cpython-131901
# New REPL on Windows exits when accented character is pasted/typed # Crash report ### What happened? When pasting an accented character like ñ or é, or typing one such as ´p and pressing Enter, then up arrow, the new REPL on Windows will exit with the following error: ```python Python 3.14.0a6+ (heads/fix_non_string_candidates_exit_repl-dirty:8008a588342, Mar 29 2025, 08:15:) [MSC v.1943 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\__main__.py", line 6, in <module> __pyrepl_interactive_console() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\main.py", line 59, in interactive_console run_multiline_interactive_console(console) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\simple_interact.py", line 137, in run_multiline_interactive_console statement = multiline_input(more_lines, ps1, ps2) File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\readline.py", line 389, in multiline_input return reader.readline() ~~~~~~~~~~~~~~~^^ File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\reader.py", line 750, in readline self.handle1() ~~~~~~~~~~~~^^ File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\reader.py", line 706, in handle1 event = self.console.get_event(block=False) File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\windows_console.py", line 471, in get_event self.event_queue.push(rec.Event.KeyEvent.uChar.UnicodeChar) ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\base_eventqueue.py", line 88, in push assert len(self.buf) == 1 ^^^^^^^^^^^^^^^^^^ AssertionError ``` In these cases, `len(self.buf)` is 3 instead of 1. I'm running Python in Windows Terminal, `chcp` gives 850, changing it to 65001 (UTF-8) makes no difference. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows ### Output from running 'python -VV' on the command line: Python 3.14.0a6+ (heads/main-dirty:7c3692fe275, Mar 24 2025, 19:20:37) [MSC v.1942 64 bit (AMD64)] <!-- gh-linked-prs --> ### Linked PRs * gh-131901 * gh-131910 * gh-133030 * gh-133445 * gh-133468 <!-- /gh-linked-prs -->
0c5151bc81ec8e8588bef4389df12a9ab50e9fa0
d6078ed6d0cb8745460769bbb5dd2392c91c2f55
python/cpython
python__cpython-131866
# Systemtap on linux does not properly apply hardening CFLAGS when compiling using --with-dtrace # Bug report ### Bug description: When compiling using --with-dtrace, Linux uses the systemtap script which utilizes a common default CFLAGS set to provide the object file. When extra hardening flags are passed during the compilation through the build environment, dtrace is not capturing them, resulting in the final binary or shared library missing some protections. This behavior was documented [recently](https://sourceware.org/git/?p=systemtap.git;a=blobdiff;f=man/dtrace.1;h=ac49c06bff776a1bc78d1c8fd0ed7b99392f2171;hp=225f9301246ebeaa38e56288e8d7d25f22d629f6;hb=1b6ef910d381fca7338de1cd75065081e6bb5f1b;hpb=adfb8019972ba4721657c98acb8dd0045da7ca80) Discovered when testing the -mbranch-protection=standard on aarch64 where pydtrace.o was missing the proper gnu property and the relevant hardware protections. See https://bugzilla.redhat.com/show_bug.cgi?id=2350935 In order to fix that, adding the CFLAGS variable to the Makefile before the dtrace invocation resolves the issue. On systems that use the original dtrace, changing the CFLAGS there should have no effects. php dealt with a similar issue before, see: https://github.com/php/php-src/commit/717b367085d55528cad82716bc5ad9736831540f https://github.com/php/php-src/commit/475fd29527ffd86297e7cd61fd1617a7374c5220 https://github.com/php/php-src/commit/02b3fb1f6bbfc78c6c015b2300e22b1675c39747 ### CPython versions tested on: CPython main branch, 3.14, 3.13, 3.12, 3.11, 3.10, 3.9 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131866 * gh-131950 * gh-131951 <!-- /gh-linked-prs -->
0cd4befb02df07c0b320cd6246227c13e57b2efb
51e0f2b06c042b8742145ce094323a34b61f02aa
python/cpython
python__cpython-131854
# `msgfmt.py`: Test validity of generated file # Feature or enhancement ### Proposal: Test the header of the binary .mo file is generated correctly and is as expected for example the start of a `msgfmt.py` generated file: ``` de12 0495 0000 0000 0900 0000 1c00 0000 6400 0000 0000 0000 0000 0000 0000 0000 ``` de12 0495 - magic number 0000 0000 - version 0900 0000 - # of entries 1c00 0000 - start of key index 6400 0000 - size of value table 0000 0000 - size of hash table 0000 0000 - offset of hash table We currently do not test the structure of the `.mo` though it is partially covered as I presume the translation tests may fail but that depends on `gettext`. Testing the last four will result in errors with a `msgfmt.c` generated `general.mo` as `msgfmt.c` generates a hash table (this will change soon I hope as we will too https://github.com/python/cpython/issues/131725 :-) so I think we should just test the first 3 for now and test the rest later. I will send a pr ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131854 * gh-131879 <!-- /gh-linked-prs -->
fccf9ab33d0b16e6171c533d139b6118503197c1
be2d2181e62cd138b0cdf80ebc0dd4058187c52a
python/cpython
python__cpython-131880
# `msgfmt.py`: Handling of header inconsistent with GNU `msgfmt` # Bug report ### Bug description: Running our current tests with a GNU generated `general.mo` we have a failure: <details> ```python SubTest failure: Traceback (most recent call last): File "/home/stan/PycharmProjects/cpython/Lib/unittest/case.py", line 58, in testPartExecutor yield File "/home/stan/PycharmProjects/cpython/Lib/unittest/case.py", line 556, in subTest yield File "/home/stan/PycharmProjects/cpython/Lib/test/test_tools/test_msgfmt.py", line 55, in test_compilation self.assertDictEqual(actual._catalog, expected._catalog) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: {'': [35 chars]N\nPOT-Creation-Date: 2024-10-26 18:06+0200\nP[563 chars]bar'} != {'': [35 chars]N\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLa[521 chars]bar'} {'': 'Project-Id-Version: PACKAGE VERSION\n' - 'POT-Creation-Date: 2024-10-26 18:06+0200\n' 'PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n' 'Last-Translator: FULL NAME <EMAIL@ADDRESS>\n' 'Language-Team: LANGUAGE <LL@li.org>\n' 'MIME-Version: 1.0\n' 'Content-Type: text/plain; charset=UTF-8\n' 'Content-Transfer-Encoding: 8bit\n', '\n newlines \n': '\n translated \n', '"escapes"': '"translated"', 'Multilinestring': 'Multilinetranslation', 'abc\x04foo': 'bar', 'bar': 'baz', 'xyz\x04foo': 'bar', ('One email sent.', 0): 'One email sent.', ('One email sent.', 1): '%d emails sent.', ('abc\x04One email sent.', 0): 'One email sent.', ('abc\x04One email sent.', 1): '%d emails sent.'} One or more subtests failed Failed subtests list: (po_file=PosixPath('/home/stan/PycharmProjects/cpython/Lib/test/test_tools/msgfmt_data/general_po')) Ran 13 tests in 0.375s FAILED (failures=1) ``` </details> This is because of a difference in what information is compiled from `general.po` header: https://github.com/python/cpython/blob/4d4e32f3da88b4d6e2fd1df2514c83c42d0150b3/Lib/test/test_tools/msgfmt_data/general.po#L3-L10 `msgfmt.py` includes `"POT-Creation-Date: 2024-10-26 18:06+0200\n"` in the binary mo file whereas `msgfmt.c` does not. <details> <summary>Binary file diff</summary> ```bash $ colordiff -y <(xxd messages.mo) <(xxd general.mo) 00000000: de12 0495 0000 0000 0900 0000 1c00 0000 .......... 00000000: de12 0495 0000 0000 0900 0000 1c00 0000 .......... 00000010: 6400 0000 0d00 0000 ac00 0000 0000 0000 d......... | 00000010: 6400 0000 0000 0000 0000 0000 0000 0000 d......... 00000020: e000 0000 0c00 0000 e100 0000 0900 0000 .......... | 00000020: ac00 0000 0c00 0000 ad00 0000 0900 0000 .......... 00000030: ee00 0000 0f00 0000 f800 0000 1f00 0000 .......... | 00000030: ba00 0000 0f00 0000 c400 0000 1f00 0000 .......... 00000040: 0801 0000 2300 0000 2801 0000 0700 0000 ....#...(. | 00000040: d400 0000 2300 0000 f400 0000 0700 0000 ....#..... 00000050: 4c01 0000 0300 0000 5401 0000 0700 0000 L.......T. | 00000050: 1801 0000 0300 0000 2001 0000 0700 0000 ........ . 00000060: 5801 0000 f500 0000 6001 0000 0e00 0000 X.......`. | 00000060: 2401 0000 1e01 0000 2c01 0000 0e00 0000 $.......,. 00000070: 5602 0000 0c00 0000 6502 0000 1400 0000 V.......e. | 00000070: 4b02 0000 0c00 0000 5a02 0000 1400 0000 K.......Z. 00000080: 7202 0000 1f00 0000 8702 0000 1f00 0000 r......... | 00000080: 6702 0000 1f00 0000 7c02 0000 1f00 0000 g.......|. 00000090: a702 0000 0300 0000 c702 0000 0300 0000 .......... | 00000090: 9c02 0000 0300 0000 bc02 0000 0300 0000 .......... 000000a0: cb02 0000 0300 0000 cf02 0000 0100 0000 .......... | 000000a0: c002 0000 0300 0000 c402 0000 000a 206e .......... 000000b0: 0300 0000 0000 0000 0800 0000 0900 0000 .......... | 000000b0: 6577 6c69 6e65 7320 0a00 2265 7363 6170 ewlines .. 000000c0: 0700 0000 0200 0000 0000 0000 0400 0000 .......... | 000000c0: 6573 2200 4d75 6c74 696c 696e 6573 7472 es".Multil 000000d0: 0500 0000 0000 0000 0600 0000 0000 0000 .......... | 000000d0: 696e 6700 4f6e 6520 656d 6169 6c20 7365 ing.One em 000000e0: 000a 206e 6577 6c69 6e65 7320 0a00 2265 .. newline | 000000e0: 6e74 2e00 2564 2065 6d61 696c 7320 7365 nt..%d ema 000000f0: 7363 6170 6573 2200 4d75 6c74 696c 696e scapes".Mu | 000000f0: 6e74 2e00 6162 6304 4f6e 6520 656d 6169 nt..abc.On 00000100: 6573 7472 696e 6700 4f6e 6520 656d 6169 estring.On | 00000100: 6c20 7365 6e74 2e00 2564 2065 6d61 696c l sent..%d 00000110: 6c20 7365 6e74 2e00 2564 2065 6d61 696c l sent..%d | 00000110: 7320 7365 6e74 2e00 6162 6304 666f 6f00 s sent..ab 00000120: 7320 7365 6e74 2e00 6162 6304 4f6e 6520 s sent..ab | 00000120: 6261 7200 7879 7a04 666f 6f00 5072 6f6a bar.xyz.fo 00000130: 656d 6169 6c20 7365 6e74 2e00 2564 2065 email sent | 00000130: 6563 742d 4964 2d56 6572 7369 6f6e 3a20 ect-Id-Ver 00000140: 6d61 696c 7320 7365 6e74 2e00 6162 6304 mails sent | 00000140: 5041 434b 4147 4520 5645 5253 494f 4e0a PACKAGE VE 00000150: 666f 6f00 6261 7200 7879 7a04 666f 6f00 foo.bar.xy | 00000150: 504f 542d 4372 6561 7469 6f6e 2d44 6174 POT-Creati 00000160: 5072 6f6a 6563 742d 4964 2d56 6572 7369 Project-Id | 00000160: 653a 2032 3032 342d 3130 2d32 3620 3138 e: 2024-10 00000170: 6f6e 3a20 5041 434b 4147 4520 5645 5253 on: PACKAG | 00000170: 3a30 362b 3032 3030 0a50 4f2d 5265 7669 :06+0200.P 00000180: 494f 4e0a 504f 2d52 6576 6973 696f 6e2d ION.PO-Rev | 00000180: 7369 6f6e 2d44 6174 653a 2059 4541 522d sion-Date: 00000190: 4461 7465 3a20 5945 4152 2d4d 4f2d 4441 Date: YEAR | 00000190: 4d4f 2d44 4120 484f 3a4d 492b 5a4f 4e45 MO-DA HO:M 000001a0: 2048 4f3a 4d49 2b5a 4f4e 450a 4c61 7374 HO:MI+ZON | 000001a0: 0a4c 6173 742d 5472 616e 736c 6174 6f72 .Last-Tran 000001b0: 2d54 7261 6e73 6c61 746f 723a 2046 554c -Translato | 000001b0: 3a20 4655 4c4c 204e 414d 4520 3c45 4d41 : FULL NAM 000001c0: 4c20 4e41 4d45 203c 454d 4149 4c40 4144 L NAME <EM | 000001c0: 494c 4041 4444 5245 5353 3e0a 4c61 6e67 IL@ADDRESS 000001d0: 4452 4553 533e 0a4c 616e 6775 6167 652d DRESS>.Lan | 000001d0: 7561 6765 2d54 6561 6d3a 204c 414e 4755 uage-Team: 000001e0: 5465 616d 3a20 4c41 4e47 5541 4745 203c Team: LANG | 000001e0: 4147 4520 3c4c 4c40 6c69 2e6f 7267 3e0a AGE <LL@li 000001f0: 4c4c 406c 692e 6f72 673e 0a4d 494d 452d LL@li.org> | 000001f0: 4d49 4d45 2d56 6572 7369 6f6e 3a20 312e MIME-Versi 00000200: 5665 7273 696f 6e3a 2031 2e30 0a43 6f6e Version: 1 | 00000200: 300a 436f 6e74 656e 742d 5479 7065 3a20 0.Content- 00000210: 7465 6e74 2d54 7970 653a 2074 6578 742f tent-Type: | 00000210: 7465 7874 2f70 6c61 696e 3b20 6368 6172 text/plain 00000220: 706c 6169 6e3b 2063 6861 7273 6574 3d55 plain; cha | 00000220: 7365 743d 5554 462d 380a 436f 6e74 656e set=UTF-8. 00000230: 5446 2d38 0a43 6f6e 7465 6e74 2d54 7261 TF-8.Conte | 00000230: 742d 5472 616e 7366 6572 2d45 6e63 6f64 t-Transfer 00000240: 6e73 6665 722d 456e 636f 6469 6e67 3a20 nsfer-Enco | 00000240: 696e 673a 2038 6269 740a 000a 2074 7261 ing: 8bit. 00000250: 3862 6974 0a00 0a20 7472 616e 736c 6174 8bit... tr | 00000250: 6e73 6c61 7465 6420 0a00 2274 7261 6e73 nslated .. 00000260: 6564 200a 0022 7472 616e 736c 6174 6564 ed .."tran | 00000260: 6c61 7465 6422 004d 756c 7469 6c69 6e65 lated".Mul 00000270: 2200 4d75 6c74 696c 696e 6574 7261 6e73 ".Multilin | 00000270: 7472 616e 736c 6174 696f 6e00 4f6e 6520 translatio 00000280: 6c61 7469 6f6e 004f 6e65 2065 6d61 696c lation.One | 00000280: 656d 6169 6c20 7365 6e74 2e00 2564 2065 email sent 00000290: 2073 656e 742e 0025 6420 656d 6169 6c73 sent..%d | 00000290: 6d61 696c 7320 7365 6e74 2e00 4f6e 6520 mails sent 000002a0: 2073 656e 742e 004f 6e65 2065 6d61 696c sent..One | 000002a0: 656d 6169 6c20 7365 6e74 2e00 2564 2065 email sent 000002b0: 2073 656e 742e 0025 6420 656d 6169 6c73 sent..%d | 000002b0: 6d61 696c 7320 7365 6e74 2e00 6261 7200 mails sent 000002c0: 2073 656e 742e 0062 6172 0062 617a 0062 sent..bar | 000002c0: 6261 7a00 6261 7200 baz.bar. 000002d0: 6172 00 ar. < ``` </details> This is an inconsistency and I presume we want to be consistent with files generated by the GNU versions looking at tests. I discovered this when working on https://github.com/python/cpython/issues/131725 Where if you remove the problematic line from the header and generate the .mo with my patch you get %100 consistency with the `msgfmt.c` generated .mo <details> <summary> No diff </summary> ```colordiff $ colordiff -y <(xxd messages.mo) <(xxd general.mo) 00000000: de12 0495 0000 0000 0900 0000 1c00 0000 .......... 00000000: de12 0495 0000 0000 0900 0000 1c00 0000 .......... 00000010: 6400 0000 0d00 0000 ac00 0000 0000 0000 d......... 00000010: 6400 0000 0d00 0000 ac00 0000 0000 0000 d......... 00000020: e000 0000 0c00 0000 e100 0000 0900 0000 .......... 00000020: e000 0000 0c00 0000 e100 0000 0900 0000 .......... 00000030: ee00 0000 0f00 0000 f800 0000 1f00 0000 .......... 00000030: ee00 0000 0f00 0000 f800 0000 1f00 0000 .......... 00000040: 0801 0000 2300 0000 2801 0000 0700 0000 ....#...(. 00000040: 0801 0000 2300 0000 2801 0000 0700 0000 ....#...(. 00000050: 4c01 0000 0300 0000 5401 0000 0700 0000 L.......T. 00000050: 4c01 0000 0300 0000 5401 0000 0700 0000 L.......T. 00000060: 5801 0000 f500 0000 6001 0000 0e00 0000 X.......`. 00000060: 5801 0000 f500 0000 6001 0000 0e00 0000 X.......`. 00000070: 5602 0000 0c00 0000 6502 0000 1400 0000 V.......e. 00000070: 5602 0000 0c00 0000 6502 0000 1400 0000 V.......e. 00000080: 7202 0000 1f00 0000 8702 0000 1f00 0000 r......... 00000080: 7202 0000 1f00 0000 8702 0000 1f00 0000 r......... 00000090: a702 0000 0300 0000 c702 0000 0300 0000 .......... 00000090: a702 0000 0300 0000 c702 0000 0300 0000 .......... 000000a0: cb02 0000 0300 0000 cf02 0000 0100 0000 .......... 000000a0: cb02 0000 0300 0000 cf02 0000 0100 0000 .......... 000000b0: 0300 0000 0000 0000 0800 0000 0900 0000 .......... 000000b0: 0300 0000 0000 0000 0800 0000 0900 0000 .......... 000000c0: 0700 0000 0200 0000 0000 0000 0400 0000 .......... 000000c0: 0700 0000 0200 0000 0000 0000 0400 0000 .......... 000000d0: 0500 0000 0000 0000 0600 0000 0000 0000 .......... 000000d0: 0500 0000 0000 0000 0600 0000 0000 0000 .......... 000000e0: 000a 206e 6577 6c69 6e65 7320 0a00 2265 .. newline 000000e0: 000a 206e 6577 6c69 6e65 7320 0a00 2265 .. newline 000000f0: 7363 6170 6573 2200 4d75 6c74 696c 696e scapes".Mu 000000f0: 7363 6170 6573 2200 4d75 6c74 696c 696e scapes".Mu 00000100: 6573 7472 696e 6700 4f6e 6520 656d 6169 estring.On 00000100: 6573 7472 696e 6700 4f6e 6520 656d 6169 estring.On 00000110: 6c20 7365 6e74 2e00 2564 2065 6d61 696c l sent..%d 00000110: 6c20 7365 6e74 2e00 2564 2065 6d61 696c l sent..%d 00000120: 7320 7365 6e74 2e00 6162 6304 4f6e 6520 s sent..ab 00000120: 7320 7365 6e74 2e00 6162 6304 4f6e 6520 s sent..ab 00000130: 656d 6169 6c20 7365 6e74 2e00 2564 2065 email sent 00000130: 656d 6169 6c20 7365 6e74 2e00 2564 2065 email sent 00000140: 6d61 696c 7320 7365 6e74 2e00 6162 6304 mails sent 00000140: 6d61 696c 7320 7365 6e74 2e00 6162 6304 mails sent 00000150: 666f 6f00 6261 7200 7879 7a04 666f 6f00 foo.bar.xy 00000150: 666f 6f00 6261 7200 7879 7a04 666f 6f00 foo.bar.xy 00000160: 5072 6f6a 6563 742d 4964 2d56 6572 7369 Project-Id 00000160: 5072 6f6a 6563 742d 4964 2d56 6572 7369 Project-Id 00000170: 6f6e 3a20 5041 434b 4147 4520 5645 5253 on: PACKAG 00000170: 6f6e 3a20 5041 434b 4147 4520 5645 5253 on: PACKAG 00000180: 494f 4e0a 504f 2d52 6576 6973 696f 6e2d ION.PO-Rev 00000180: 494f 4e0a 504f 2d52 6576 6973 696f 6e2d ION.PO-Rev 00000190: 4461 7465 3a20 5945 4152 2d4d 4f2d 4441 Date: YEAR 00000190: 4461 7465 3a20 5945 4152 2d4d 4f2d 4441 Date: YEAR 000001a0: 2048 4f3a 4d49 2b5a 4f4e 450a 4c61 7374 HO:MI+ZON 000001a0: 2048 4f3a 4d49 2b5a 4f4e 450a 4c61 7374 HO:MI+ZON 000001b0: 2d54 7261 6e73 6c61 746f 723a 2046 554c -Translato 000001b0: 2d54 7261 6e73 6c61 746f 723a 2046 554c -Translato 000001c0: 4c20 4e41 4d45 203c 454d 4149 4c40 4144 L NAME <EM 000001c0: 4c20 4e41 4d45 203c 454d 4149 4c40 4144 L NAME <EM 000001d0: 4452 4553 533e 0a4c 616e 6775 6167 652d DRESS>.Lan 000001d0: 4452 4553 533e 0a4c 616e 6775 6167 652d DRESS>.Lan 000001e0: 5465 616d 3a20 4c41 4e47 5541 4745 203c Team: LANG 000001e0: 5465 616d 3a20 4c41 4e47 5541 4745 203c Team: LANG 000001f0: 4c4c 406c 692e 6f72 673e 0a4d 494d 452d LL@li.org> 000001f0: 4c4c 406c 692e 6f72 673e 0a4d 494d 452d LL@li.org> 00000200: 5665 7273 696f 6e3a 2031 2e30 0a43 6f6e Version: 1 00000200: 5665 7273 696f 6e3a 2031 2e30 0a43 6f6e Version: 1 00000210: 7465 6e74 2d54 7970 653a 2074 6578 742f tent-Type: 00000210: 7465 6e74 2d54 7970 653a 2074 6578 742f tent-Type: 00000220: 706c 6169 6e3b 2063 6861 7273 6574 3d55 plain; cha 00000220: 706c 6169 6e3b 2063 6861 7273 6574 3d55 plain; cha 00000230: 5446 2d38 0a43 6f6e 7465 6e74 2d54 7261 TF-8.Conte 00000230: 5446 2d38 0a43 6f6e 7465 6e74 2d54 7261 TF-8.Conte 00000240: 6e73 6665 722d 456e 636f 6469 6e67 3a20 nsfer-Enco 00000240: 6e73 6665 722d 456e 636f 6469 6e67 3a20 nsfer-Enco 00000250: 3862 6974 0a00 0a20 7472 616e 736c 6174 8bit... tr 00000250: 3862 6974 0a00 0a20 7472 616e 736c 6174 8bit... tr 00000260: 6564 200a 0022 7472 616e 736c 6174 6564 ed .."tran 00000260: 6564 200a 0022 7472 616e 736c 6174 6564 ed .."tran 00000270: 2200 4d75 6c74 696c 696e 6574 7261 6e73 ".Multilin 00000270: 2200 4d75 6c74 696c 696e 6574 7261 6e73 ".Multilin 00000280: 6c61 7469 6f6e 004f 6e65 2065 6d61 696c lation.One 00000280: 6c61 7469 6f6e 004f 6e65 2065 6d61 696c lation.One 00000290: 2073 656e 742e 0025 6420 656d 6169 6c73 sent..%d 00000290: 2073 656e 742e 0025 6420 656d 6169 6c73 sent..%d 000002a0: 2073 656e 742e 004f 6e65 2065 6d61 696c sent..One 000002a0: 2073 656e 742e 004f 6e65 2065 6d61 696c sent..One 000002b0: 2073 656e 742e 0025 6420 656d 6169 6c73 sent..%d 000002b0: 2073 656e 742e 0025 6420 656d 6169 6c73 sent..%d 000002c0: 2073 656e 742e 0062 6172 0062 617a 0062 sent..bar 000002c0: 2073 656e 742e 0062 6172 0062 617a 0062 sent..bar 000002d0: 6172 00 ar. 000002d0: 6172 00 ar. ``` </details> ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131880 * gh-132216 * gh-132217 <!-- /gh-linked-prs -->
ad6a032cebf59d1668caa7e726aa5da72e1cbb5c
376631829aab72e320e19102fc55cbca5af8c733
python/cpython
python__cpython-131833
# Implement PEP 758 – Allow except and except* expressions without parentheses See PEP-758 <!-- gh-linked-prs --> ### Linked PRs * gh-131833 <!-- /gh-linked-prs -->
c2ac662f284b7c3f0701173f2467bf1e18aad2e2
053c285f6b41f92fbdd1d4ff0c959cceefacd7cd
python/cpython
python__cpython-136270
# Fix sqlite timezone-naive adapter recipe # Documentation This recipe for an adapter does not work as advertised: ``` def adapt_datetime_iso(val): """Adapt datetime.datetime to timezone-naive ISO 8601 date.""" return val.isoformat() ``` from: https://github.com/erlend-aasland/cpython/blob/a3711d1541c1b7987941b41d2247f87dae347117/Doc/library/sqlite3.rst?plain=1#L2287-L2289 or https://docs.python.org/3/library/sqlite3.html#sqlite3-adapter-converter-recipes If the argument has a timezone, it will produce a timezone-aware result, contrary to its documentation Consider the difference between these: ``` import datetime print(datetime.datetime.now(datetime.timezone.utc).isoformat()) print(datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None).isoformat()) """ 2025-03-28T08:41:09.240880+00:00 2025-03-28T08:41:09.241046 """ ``` The recipe should instead be like this: ``` def adapt_datetime_iso(val): """Adapt datetime.datetime to timezone-naive ISO 8601 date.""" return val.replace(tzinfo=None).isoformat() ``` <!-- gh-linked-prs --> ### Linked PRs * gh-136270 * gh-136467 * gh-136468 <!-- /gh-linked-prs -->
6a6cd3c07c0300c8799878a48d555470be2a52f7
3c43df4dbdb0a41b8e5503b7fa4741a29b6007e0
python/cpython
python__cpython-131819
# `python -I`'s help message missing imply `-P` # Feature or enhancement ### Proposal: According to the [doc](https://docs.python.org/3/using/cmdline.html#cmdoption-I), > -I Run Python in isolated mode. This also implies [-E](https://docs.python.org/3/using/cmdline.html#cmdoption-E), [-P](https://docs.python.org/3/using/cmdline.html#cmdoption-P) and [-s](https://docs.python.org/3/using/cmdline.html#cmdoption-s) options. But it's not motioned in the `python --help`. `-P` does not add unsafe path in `sys.path`. I think this is useful information and should be included. ![Image](https://github.com/user-attachments/assets/9b435dff-192f-42f4-8c81-0ff17ef09f53) Related PR: https://github.com/python/cpython/pull/31542 ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131819 * gh-131822 * gh-131823 <!-- /gh-linked-prs -->
8bd88e2827b2a887c2ea8e5ed0c0575704bfacdf
af2afd7c224389856e118d3f544c9621a016599f
python/cpython
python__cpython-132192
# Please upgrade bundled Expat to 2.7.1 # Bug report ### Bug description: Hi! 👋 Please upgrade bundled Expat to 2.7.1 (e.g. for the fix to what can be argued a [regression](https://github.com/libexpat/libexpat/issues/980) that came with the fix for CVE-2024-8176 in Expat 2.7.0). * GitHub release: https://github.com/libexpat/libexpat/releases/tag/R_2_7_1 * Change log: https://github.com/libexpat/libexpat/blob/R_2_7_1/expat/Changes The CPython issue for previous 2.7.0 was #131261 and the related merged main pull request was #131272, in case you want to have a look. The `Dockerfile` from comment https://github.com/python/cpython/pull/123689#pullrequestreview-2280929950 could be of help with raising confidence in a bump pull request when going forward. Thanks in advance! CC @sethmlarson @gpshead ### CPython versions tested on: 3.9, 3.10, CPython main branch, 3.14, 3.13, 3.12, 3.11 ### Operating systems tested on: Other, Windows, macOS, Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132192 * gh-132235 * gh-132236 * gh-132237 * gh-132240 * gh-132241 * gh-132242 <!-- /gh-linked-prs -->
c0de6500249469e6fc5b458d6afb6bad1b6755cd
f0dcb29d3affbbe1ec25b922235f0556bd695067
python/cpython
python__cpython-131808
# ResourceWarning in test.test_ucn.UnicodeNamesTest.test_named_sequences_full (when http request 404s) # Bug report ### Bug description: ``` $ PYTHONTRACEMALLOC=25 ./python -Walways -m unittest test.test_ucn -vvv test_aliases (test.test_ucn.UnicodeNamesTest.test_aliases) ... ok test_aliases_names_in_pua_range (test.test_ucn.UnicodeNamesTest.test_aliases_names_in_pua_range) ... ok test_ascii_letters (test.test_ucn.UnicodeNamesTest.test_ascii_letters) ... ok test_bmp_characters (test.test_ucn.UnicodeNamesTest.test_bmp_characters) ... ok test_cjk_unified_ideographs (test.test_ucn.UnicodeNamesTest.test_cjk_unified_ideographs) ... ok test_errors (test.test_ucn.UnicodeNamesTest.test_errors) ... ok test_general (test.test_ucn.UnicodeNamesTest.test_general) ... ok test_hangul_syllables (test.test_ucn.UnicodeNamesTest.test_hangul_syllables) ... ok test_issue16335 (test.test_ucn.UnicodeNamesTest.test_issue16335) ... skipped 'not enough memory: 12.0G minimum needed' test_misc_symbols (test.test_ucn.UnicodeNamesTest.test_misc_symbols) ... ok test_named_sequences_full (test.test_ucn.UnicodeNamesTest.test_named_sequences_full) ... fetching http://www.pythontest.net/unicode/15.1.0/NamedSequences.txt ... skipped "Could not retrieve http://www.pythontest.net/unicode/15.1.0/NamedSequences.txt e=<HTTPError 404: 'Not Found'>" test_named_sequences_names_in_pua_range (test.test_ucn.UnicodeNamesTest.test_named_sequences_names_in_pua_range) ... ok test_named_sequences_sample (test.test_ucn.UnicodeNamesTest.test_named_sequences_sample) ... ok test_strict_error_handling (test.test_ucn.UnicodeNamesTest.test_strict_error_handling) ... ok ---------------------------------------------------------------------- Ran 14 tests in 4.010s OK (skipped=2) <sys>:0: ResourceWarning: unclosed <socket.socket [closed] fd=3, family=2, type=1, proto=6> Object allocated at (most recent call last): File "/home/graingert/projects/cpython/Lib/unittest/main.py", lineno 270 self.result = testRunner.run(self.test) File "/home/graingert/projects/cpython/Lib/unittest/runner.py", lineno 240 test(result) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 84 return self.run(*args, **kwds) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 122 test(result) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 84 return self.run(*args, **kwds) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 122 test(result) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 84 return self.run(*args, **kwds) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 122 test(result) File "/home/graingert/projects/cpython/Lib/unittest/case.py", lineno 707 return self.run(*args, **kwds) File "/home/graingert/projects/cpython/Lib/unittest/case.py", lineno 651 self._callTestMethod(testMethod) File "/home/graingert/projects/cpython/Lib/unittest/case.py", lineno 606 if method() is not None: File "/home/graingert/projects/cpython/Lib/test/test_ucn.py", lineno 182 testdata = support.open_urlresource(url, encoding="utf-8", File "/home/graingert/projects/cpython/Lib/test/support/__init__.py", lineno 741 f = opener.open(url, timeout=INTERNET_TIMEOUT) File "/home/graingert/projects/cpython/Lib/urllib/request.py", lineno 489 response = self._open(req, data) File "/home/graingert/projects/cpython/Lib/urllib/request.py", lineno 506 result = self._call_chain(self.handle_open, protocol, protocol + File "/home/graingert/projects/cpython/Lib/urllib/request.py", lineno 466 result = func(*args) File "/home/graingert/projects/cpython/Lib/urllib/request.py", lineno 1348 return self.do_open(http.client.HTTPConnection, req) File "/home/graingert/projects/cpython/Lib/urllib/request.py", lineno 1319 h.request(req.get_method(), req.selector, req.data, headers, File "/home/graingert/projects/cpython/Lib/http/client.py", lineno 1338 self._send_request(method, url, body, headers, encode_chunked) File "/home/graingert/projects/cpython/Lib/http/client.py", lineno 1384 self.endheaders(body, encode_chunked=encode_chunked) File "/home/graingert/projects/cpython/Lib/http/client.py", lineno 1333 self._send_output(message_body, encode_chunked=encode_chunked) File "/home/graingert/projects/cpython/Lib/http/client.py", lineno 1093 self.send(msg) File "/home/graingert/projects/cpython/Lib/http/client.py", lineno 1037 self.connect() File "/home/graingert/projects/cpython/Lib/http/client.py", lineno 1003 self.sock = self._create_connection( File "/home/graingert/projects/cpython/Lib/socket.py", lineno 844 sock = socket(af, socktype, proto) ``` ### CPython versions tested on: 3.14, CPython main branch, 3.13 ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131808 * gh-131845 * gh-131846 <!-- /gh-linked-prs -->
adb67ed7e465410829ac0b1f903ec5678e0e51cc
27d1443897daff65e8a42269b591097f29d310c6
python/cpython
python__cpython-131859
# `signal.set_wakeup_fd` does not work unless you register a no-op signal handler for the relevant signal # Bug report ### Bug description: Consider this program that uses `signal.signal.set_wakeup_fd`: `demo.py`: ```python import os import signal import struct pipe_r, pipe_w = os.pipe() os.set_blocking(pipe_w, False) signal.set_wakeup_fd(pipe_w) # Conditionally register a signal handler. if os.environ["REGISTER_SIGNAL_HANDLER"] == "1": print("Registering a signal handler for SIGURG") signal.signal(signal.SIGURG, lambda signum, frame: None) else: print("Not registering a signal handler for SIGURG") # Send the signal! print("Sending myself a SIGURG") signal.raise_signal(signal.SIGURG) # Verify that we wrote the signal to the pipe. print("About to read from pipe_r") data = os.read(pipe_r, 1) (raised, ) = struct.unpack('%uB' % len(data), data) if raised != signal.SIGURG: raise Exception("%r != %r" % (raised, signal.SIGURG)) os.close(pipe_r) os.close(pipe_w) print("Success!") ``` If I run this with `REGISTER_SIGNAL_HANDLER=1`, it works: ```console $ REGISTER_SIGNAL_HANDLER=1 python demo.py Registering a signal handler for SIGURG Sending myself a SIGURG About to read from pipe_r Success! ``` However, if I run this without registering the signal handler, it hangs indefinitely: ```console $ REGISTER_SIGNAL_HANDLER=0 python demo.py Not registering a signal handler for SIGURG Sending myself a SIGURG About to read from pipe_r ``` All the real world usages I've been able to find of `signal.set_wakeup_fd` register a no-op signal handler for the signal(s) they're interested in. For example, see this CPython test: https://github.com/python/cpython/blob/8a00c9a4d2ce9d373b13f8f0a2265a65f4523293/Lib/test/test_signal.py#L340. I don't know if we would consider this is a bug in the implementation or a bug in the documentation, but IMO, it's a pretty confusing experience for people who don't know this. Some ideas: - Change `signal.set_wakeup_fd` to register a no-op signal handler for you if there isn't a corresponding signal handler already registered. - Change `signal.set_wakeup_fd` to error out if there is no signal handler already registered. - Update the docs to mention this requirement: https://docs.python.org/3/library/signal.html#signal.set_wakeup_fd I'd be happy to implement some of these ideas if folks tell me what seems best! ### CPython versions tested on: 3.12 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131859 * gh-132522 <!-- /gh-linked-prs -->
939476bbbb57ec3348c60df7c8f67c92038c8c89
8768df2fe94a8444baff47a5b8c7414a2118731a
python/cpython
python__cpython-131783
# Cast error with _Py_TryIncrefCompareStackRef and -Wc++11-narrowing # Bug report ### Bug description: The current `main` branch fails to build if the `-Wc++11-narrowing` option is used: ``` internal/pycore_stackref.h:649:39: error: non-constant-expression cannot be narrowed from type 'intptr_t' (aka 'long') to 'uintptr_t' (aka 'unsigned long') in initializer list [-Wc++11-narrowing] 649 | *out = (_PyStackRef){ .bits = (intptr_t)op | Py_TAG_DEFERRED }; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` The fix is to change the cast to `uintptr_t` which matches the type of `.bits`. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131783 <!-- /gh-linked-prs -->
c824d8e6f96a2c36c9f955f3be6138caaae35bfa
151d1bfd1bb7ca9a36bb0f2bd6df53d64a1ba2f2
python/cpython
python__cpython-131844
# Parser stack overflow on WASI with `--with-pydebug` # Bug report ### Bug description: ```pytb $ python Tools/wasm/wasi.py configure-build-python -- --with-pydebug ... $ python Tools/wasm/wasi.py make-build-python ... $ python Tools/wasm/wasi.py configure-host -- --with-pydebug ... $ python Tools/wasm/wasi.py make-host ... $ wasmtime run --dir .::/ cross-build/wasm32-wasip1/python.wasm -m test.test_compile Traceback (most recent call last): File "/Lib/runpy.py", line 189, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ File "/Lib/runpy.py", line 159, in _get_module_details code = loader.get_code(mod_name) File "<frozen importlib._bootstrap_external>", line 896, in get_code File "<frozen importlib._bootstrap_external>", line 826, in source_to_code File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed MemoryError: Parser stack overflowed - Python source too complex to parse ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ **NOTE** The failing tests have shifted; see https://github.com/python/cpython/issues/131770#issuecomment-2856268358 <!-- gh-linked-prs --> ### Linked PRs * gh-131844 <!-- /gh-linked-prs -->
6ab4acecf91413fccd39f78ff14775d83498dab5
0dbaeb94a8b39972ebda7782b50bb49488951e3c
python/cpython
python__cpython-131765
# Unnecessary NULL check for `code->_co_monitoring` in `remove_tools` If [monitoring](https://github.com/python/cpython/blob/ac12de2e6a6f5c1da83de0412bb7d03c28fdab63/Python/instrumentation.c#L837) variable is equal to NULL then we'll get segmentation fault in [line 843](https://github.com/python/cpython/blob/ac12de2e6a6f5c1da83de0412bb7d03c28fdab63/Python/instrumentation.c#L843) since [monitoring = code->_co_monitoring](https://github.com/python/cpython/blob/ac12de2e6a6f5c1da83de0412bb7d03c28fdab63/Python/instrumentation.c#L835). Otherwise, the if statement is incorrect. <!-- gh-linked-prs --> ### Linked PRs * gh-131765 <!-- /gh-linked-prs -->
151d1bfd1bb7ca9a36bb0f2bd6df53d64a1ba2f2
52b5eb95b770fa00ebbd449ba40cab4a0e7c7df7
python/cpython
python__cpython-131764
# Dereferencing the pointer 'parser_token->metadata' with a NULL value After having been assigned to a NULL value https://github.com/python/cpython/blob/ac12de2e6a6f5c1da83de0412bb7d03c28fdab63/Parser/pegen.c#L194 pointer 'parser_token->metadata' is passed as 3rd parameter in call to function 'Py_DECREF': https://github.com/python/cpython/blob/ac12de2e6a6f5c1da83de0412bb7d03c28fdab63/Parser/pegen.c#L197 where it is dereferenced. Metadata for a new_token can be set using fstrings, such as `{1!=2=}`. If _PyArena_AddPyObject returns -1, we will get a read access violation exception. <!-- gh-linked-prs --> ### Linked PRs * gh-131764 * gh-131774 * gh-131775 <!-- /gh-linked-prs -->
2c686a9ac243800b630d4a09622c8eb789f5b354
67fbfb42bd5dfe861d0c58d9e6c48d8eef033d24
python/cpython
python__cpython-131758
# functools.lru_cache prevents function being cached from executing concurrently under free-threading # Feature or enhancement ### Proposal: `functools.lru_cache` was made free-thread safe but is not so in an efficient way. It works currently by serializing the function being cached and preventing it from executing concurrently even if it can. Effectively, for the function being cached, it is as if the GIL still exists. ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131758 <!-- /gh-linked-prs -->
4c12a2db15639fe1b28f1f0f807a18fb7b71d851
45c447bf91ffabe4c0ba6d18f37d4e58925d5c91
python/cpython
python__cpython-131742
# "What's new" notes for 3.12 don't mention `platform` changes regarding Windows 11 detection # Documentation Python 3.12 updated `platform` to the (at the time) latest state, which added platform string changes to support Windows 11. We have code that was written prior to 3.12's release that worked around `platform` labeling Windows 11 as `Windows-10`, which was broken by this change. (An incredibly tiny change that took a minute to fix on our end, but could confuse other developers with many more dependencies who may think some other dependency broke it) This isn't mentioned in the "What's New" page or the full changelog, and both `3.12` and `3.11` have the same `__version__` for `platform` -- `1.0.8`. I've added a note to the 3.12 "What's New" page to document this, in the `gh-131742` PR. <!-- gh-linked-prs --> ### Linked PRs * gh-131742 * gh-131767 * gh-131768 <!-- /gh-linked-prs -->
b9ca438daab6a4e2513ab38171e94c75da03d6e3
2d83891dfd51f595de68b0336b3bfc876f7b2507
python/cpython
python__cpython-131744
# PyUnstable_GC_VisitObjects should traverse the permanent generation as well # Bug report ### Bug description: This function is meant to walk the heap and visit all GCable objects. It currently ignores the permanent / frozen generation, which is a problem when calling code expects to get all extant objects. As a concrete example, the cinder JIT compiler uses this function to scan through all Python functions on the heap and try JIT compiling them. Functions that have been frozen by `gc.freeze()` or `immortalize_heap()` are not processed, and thus do not get compiled. ### CPython versions tested on: 3.12 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131744 * gh-131754 * gh-131828 * gh-131786 <!-- /gh-linked-prs -->
7bb41aef4b7b8f3c3f07c11b801c5b7f8afaac7f
a26a301f8b09c1825b288fc8649f8174576361f4
python/cpython
python__cpython-131737
# optimize any/all/tuple calls with a generator expression arg See discussion in https://github.com/faster-cpython/ideas/issues/545. <!-- gh-linked-prs --> ### Linked PRs * gh-131737 <!-- /gh-linked-prs -->
2c8f329dc634290fb88636f85c05e473bc0104d5
674dbf3b3a72bd3d17298c2ead79f32edcff774a
python/cpython
python__cpython-131739
# Only do seclevel workaround if seclevel greater than 1 # Feature or enhancement ### Proposal: We propose checking libssl's current security level before performing [our ubuntu workaround](https://github.com/python/cpython/blob/main/Lib/test/test_ssl.py#L153) in `test_ssl.py`, and skipping the workaround if it's unnecessary. Due to backwards compatibility concerns around parsing short RSA keys, AWS-LC [only supports `SECLEVEL=0`](https://github.com/aws/aws-lc/pull/2065/). ### Has this already been discussed elsewhere? I have already discussed this feature proposal on Discourse ### Links to previous discussion of this feature: This issue is very similar to a series of other test modifications discussed in https://discuss.python.org/t/support-building-ssl-and-hashlib-modules-against-aws-lc/44505/13 <!-- gh-linked-prs --> ### Linked PRs * gh-131739 * gh-131966 * gh-131967 <!-- /gh-linked-prs -->
3b3720f1a26ab34377542b48eb6a6565f78ff892
23a658b9af410b72beeb28ba4ace2d83896c5631
python/cpython
python__cpython-131732
# Generated interpreter does not spill the correct value of the stack pointer for output arrays. # Bug report ### Bug description: The generated C code for `UNPACK_SEQUENCE_TUPLE` saves the stack pointer before increasing it to account for the output array. This could result in some of the items being prematurely destroyed if `seq` is deleted. https://github.com/python/cpython/blob/main/Python/generated_cases.c.h#L11927 ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131732 * gh-131773 <!-- /gh-linked-prs -->
1b8bb1ed0c4243796af531a35de982bc4f028215
b9ca438daab6a4e2513ab38171e94c75da03d6e3
python/cpython
python__cpython-136814
# http.client._MAXHEADERS = 100 limit no longer sufficient # Bug report ### Bug description: This hard-coded sanity check for HTTP response headers is no longer sufficient to fetch a Microsoft 365 page. https://github.com/python/cpython/blob/0a91456ad14bb598646f50bf8f034e8887c0c468/Lib/http/client.py#L112 I do have a case open with Microsoft Support (TrackingID#2503130010002871), but it's not getting much traction as it's not causing problems with full web browsers. Steps to reproduce: ```python import http.client con = http.client.HTTPSConnection('outlook.office365.com') con.request("GET", "/owa/example.edu") # any domain seems to trigger r = con.getresponse() ``` And that throws a HTTPException ``` >>> con = http.client.HTTPSConnection('outlook.office365.com') >>> con.request("GET", "/owa/foo.bar") >>> r = con.getresponse() Traceback (most recent call last): File "<python-input-8>", line 1, in <module> r = con.getresponse() File "C:\Users\jmacdone\AppData\Local\Programs\Python\Python313-arm64\Lib\http\client.py", line 1428, in getresponse response.begin() ~~~~~~~~~~~~~~^^ File "C:\Users\jmacdone\AppData\Local\Programs\Python\Python313-arm64\Lib\http\client.py", line 350, in begin self.headers = self.msg = parse_headers(self.fp) ~~~~~~~~~~~~~^^^^^^^^^ File "C:\Users\jmacdone\AppData\Local\Programs\Python\Python313-arm64\Lib\http\client.py", line 248, in parse_headers headers = _read_headers(fp) File "C:\Users\jmacdone\AppData\Local\Programs\Python\Python313-arm64\Lib\http\client.py", line 226, in _read_headers raise HTTPException("got more than %d headers" % _MAXHEADERS) http.client.HTTPException: got more than 100 headers >>> ``` It seems to be just spilling over with 101 headers. Though, not consistently. Presumably it depends upon which load balancer node is responding. ```bash $ curl --silent -D - 'https://outlook.office365.com/owa/example.edu' | grep -E "^[a-zA-Z-]+: " | wc -l ``` returns with 96, 99, 101, etc. headers, depending on ~Microsoft's mood~ unknown factors. For background, it's common to use `https://outlook.com/example.edu` as a domain hint ("smart link") to go directly to a tenant's identity provider and avoid the "Please provide your email address" step. We have a nagios check for that, which broke recently as the number of `Set-Cookie: OpenIdConnect.token.[...]` variants continues to grow. ### CPython versions tested on: 3.13, 3.9, 3.11 ### Operating systems tested on: Linux, Windows <!-- gh-linked-prs --> ### Linked PRs * gh-136814 <!-- /gh-linked-prs -->
958657bbc3351c66dd8e319503675521bfdea49a
18a7f5dad832488e8965fe29159a62abc18368e2
python/cpython
python__cpython-131720
# _PyMem_FreeDelayed() missing a NULL pointer check # Bug report ### Bug description: Normally this is not a problem but if `_PyMem_FreeDelayed(NULL)` is called an (quite!) improbably high number of times in a single thread it can lead to memory exhaustion because the NULL is added to a queue. Fix is just to add a NULL check like `_PyObject_XDecRefDelayed()`. ### CPython versions tested on: 3.14 ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131720 * gh-131722 <!-- /gh-linked-prs -->
0a91456ad14bb598646f50bf8f034e8887c0c468
44605aa93d31d6dff64dab96126942f94cf1dfe9
python/cpython
python__cpython-131759
# `_suggestions` module missing on Windows, untested # Bug report ### Bug description: The `_suggestions` module isn't available in Windows builds because it's missing from `PC/config.c`. Since it's not tested and only imported in `traceback.py` in a `try:` block guarding against `ImportError`, it's easy to not detect that it's missing. If there is no objection, I'll create a PR adding the `_suggestions` module to `PC/config.c` (and perhaps `config_minimal.c`) plus basic tests to detect whether it's available and working as intended. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-131759 * gh-131790 <!-- /gh-linked-prs -->
9ef9d687ff7cfc4bbf422ba61db04207b7f343d2
d836d287a7bd1392f6d011888a7469854b0f4325
python/cpython
python__cpython-131713
# Using a null pointer in set_tp_mro https://github.com/python/cpython/blob/6fb5f7f4d9d22c49f5c29d2ffcbcc32b6cd7d06a/Objects/typeobject.c#L1673 In the **mro_hierarchy** function the **old_mro** variable can get a null value from the **mro_internal** call. [There is a check for NULL](https://github.com/python/cpython/blob/6fb5f7f4d9d22c49f5c29d2ffcbcc32b6cd7d06a/Objects/typeobject.c#L1657). However, in case of errors in the **PyTuple_Pack** or **PyList_Append** functions, this null value will be passed to function **set_tp_mro**. Next, in the release build, **type->tp_mro** will simply get the NULL value, but in the debug build, the null pointer will be accessed. The expression [PyTuple_CheckExact(mro) in function set_tp_mro](https://github.com/python/cpython/blob/6fb5f7f4d9d22c49f5c29d2ffcbcc32b6cd7d06a/Objects/typeobject.c#L577) does not check the argument for NULL. <!-- gh-linked-prs --> ### Linked PRs * gh-131713 <!-- /gh-linked-prs -->
44605aa93d31d6dff64dab96126942f94cf1dfe9
f1967e72498209e42f7cf5eeff0cd84d1ec10d18
python/cpython
python__cpython-131708
# RuntimeWarning in test_coroutines.CoroutineTest.test_await_17 # Bug report ### Bug description: ``` test_await_17 (test.test_coroutines.CoroutineTest.test_await_17) ... Warning -- Unraisable exception Exception ignored while finalizing coroutine <coroutine object CoroutineTest.test_await_17.<locals>.A.__anext__ at 0x10205e970>: Traceback (most recent call last): File "/Users/admin/actions-runner/_work/cpython/cpython/Lib/warnings.py", line 700, in _warn_unawaited_coroutine warn(msg, category=RuntimeWarning, stacklevel=2, source=coro) RuntimeWarning: coroutine 'CoroutineTest.test_await_17.<locals>.A.__anext__' was never awaited ok ``` ### CPython versions tested on: 3.14, CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131708 <!-- /gh-linked-prs -->
6fb5f7f4d9d22c49f5c29d2ffcbcc32b6cd7d06a
7d9442f0d55a7169940b9371d6e58a7c2ec1fa8a
python/cpython
python__cpython-131730
# clang-cl on Windows incorrectly compiles SEH (structured exception handling) # Bug report ### Bug description: clang-cl incorrectly handles SEH exception handling: https://github.com/llvm/llvm-project/issues/62606 E.g. in https://github.com/python/cpython/blob/7c3692fe275088e986f92cec34dcccb823b31fa2/Modules/mmapmodule.c#L353-L360 where https://github.com/python/cpython/blob/7c3692fe275088e986f92cec34dcccb823b31fa2/Modules/mmapmodule.c#L297-L316 This lets `test_mmap.MmapTests.test_access_violations` fail for clang-cl builds on Windows, see e.g. https://github.com/python/cpython/actions/runs/14044831663/job/39323183797?pr=131690#step:4:566. The suggestion in https://github.com/llvm/llvm-project/issues/62606#issuecomment-1538837488 is to use `EHa`, > the problem is that without /EHa, the compiler assumes memory accesses don't trap which seems wrong, and clearly is a compatibility issue wrt to MSVC. Since Python code is compiled in C mode, `EHa` would seem really weird to me. Even more weird workaround: wrap the "body" (here `sourcecode`) in a separate function and guard that via SEH. I've tried both workarounds and they would fix the problem. ### CPython versions tested on: 3.14 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-131730 <!-- /gh-linked-prs -->
488174dc68f90217fd43aa95d87441cc6bad6a29
90b82f2b61219c8f94e2deddc989a4c4fe9ea7c7
python/cpython
python__cpython-131690
# Windows tail-call CI does not run the test cases Excerpts from here https://github.com/python/cpython/pull/131526#issuecomment-2745152513: See e.g. https://github.com/python/cpython/actions/runs/14006628024/job/39221297660 and https://github.com/python/cpython/actions/runs/13954576580/job/39062383429#step:4:326. After building, no more output can be seen. This is interesting, because https://github.com/python/cpython/blob/ce79274e9f093bd06d2285c9af48dbcbc92173de/.github/workflows/tail-call.yml#L82-L91 clearly `./PCbuild/rt.bat` is invoked. Maybe the reason is, because it is not used with backslashes like in https://github.com/python/cpython/blob/ce79274e9f093bd06d2285c9af48dbcbc92173de/.github/workflows/reusable-windows.yml#L52 The question then is, why `./PCbuild/build.bat` is working ... <!-- gh-linked-prs --> ### Linked PRs * gh-131690 <!-- /gh-linked-prs -->
ce77da5871334bffea722984cb705fd20a763a1f
adb67ed7e465410829ac0b1f903ec5678e0e51cc
python/cpython
python__cpython-131679
# Flaky test `test_lru_cache_threaded3` # Bug report Seen locally. The `with self.subTest():` is not safe to call from multiple threads concurrently because `subTest` modifies `self._subtest`, so you might end up with the wrong or `None` subtest in the call to `testPartExecutor`. https://github.com/python/cpython/blob/d372472896ca9d5666b40072a9ed7040300e11a0/Lib/test/test_functools.py#L1930-L1942 https://github.com/python/cpython/blob/d372472896ca9d5666b40072a9ed7040300e11a0/Lib/unittest/case.py#L553-L566 ``` test_lru_cache_threaded3 (test.test_functools.TestLRUC.test_lru_cache_threaded3) ... Warning -- Uncaught thread exception: AttributeError Exception in thread Thread-21 (test): Traceback (most recent call last): File "/raid/sgross/cpython/Lib/threading.py", line 1054, in _bootstrap_inner self.run() ~~~~~~~~^^ File "/raid/sgross/cpython/Lib/threading.py", line 996, in run self._target(*self._args, **self._kwargs) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/sgross/cpython/Lib/test/test_functools.py", line 1937, in test with self.subTest(thread=i): ~~~~~~~~~~~~^^^^^^^^^^ File "/raid/sgross/cpython/Lib/contextlib.py", line 148, in __exit__ next(self.gen) ~~~~^^^^^^^^^^ File "/raid/sgross/cpython/Lib/unittest/case.py", line 555, in subTest with self._outcome.testPartExecutor(self._subtest, subTest=True): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/sgross/cpython/Lib/contextlib.py", line 148, in __exit__ next(self.gen) ~~~~^^^^^^^^^^ File "/raid/sgross/cpython/Lib/unittest/case.py", line 81, in testPartExecutor self.result.addSubTest(test_case.test_case, test_case, None) ^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'test_case' ok ``` <!-- gh-linked-prs --> ### Linked PRs * gh-131679 * gh-131692 * gh-131693 <!-- /gh-linked-prs -->
a1232459860235f4fb7896cc95966d87a51cbe32
7c3692fe275088e986f92cec34dcccb823b31fa2
python/cpython
python__cpython-131784
# build: big endian ARM builds fail with mimalloc enabled # Bug report ### Bug description: Preface: I'm aware that big-endian ARM is not listed in PEP 11 where it's assumed that binaries are little endian by default. I wrote an upstream issue to track this as well: https://github.com/microsoft/mimalloc/issues/1046 build log: https://autobuild.buildroot.org/results/26b752738022e8b46e810a08e28d687120e5c4e3/build-end.log ``` /home/autobuild/autobuild/instance-4/output-1/per-package/python3/host/bin/armeb-buildroot-linux-gnueabi-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Ofast -g2 -D_FORTIFY_SOURCE=1 -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DPy_BUILD_CORE_BUILTIN -c ./Modules/_abc.c -o Modules/_abc.o In file included from ./Include/internal/mimalloc/mimalloc/types.h:24, from ./Include/internal/pycore_mimalloc.h:44, from ./Include/internal/pycore_interp.h:31, from ./Include/internal/pycore_runtime.h:17, from ./Include/internal/pycore_emscripten_trampoline.h:4, from ./Include/internal/pycore_object.h:13, from ./Modules/_abc.c:8: ./Include/internal/mimalloc/mimalloc/atomic.h:83:20: warning: 'mi_atomic_yield' declared 'static' but never defined [-Wunused-function] 83 | static inline void mi_atomic_yield(void); | ^~~~~~~~~~~~~~~ ``` This prevents CPython from linking correctly: ``` /home/autobuild/autobuild/instance-4/output-1/per-package/python3/host/bin/armeb-buildroot-linux-gnueabi-gcc -shared -Wl,--no-as-needed -o libpython3.so -Wl,-hlibpython3.so libpython3.13.so /home/autobuild/autobuild/instance-4/output-1/per-package/python3/host/bin/armeb-buildroot-linux-gnueabi-gcc -Xlinker -export-dynamic -o python Programs/python.o -L. -lpython3.13 -ldl -lpthread -latomic -lm /home/autobuild/autobuild/instance-4/output-1/per-package/python3/host/bin/../lib/gcc/armeb-buildroot-linux-gnueabi/13.3.0/../../../../armeb-buildroot-linux-gnueabi/bin/ld: ./libpython3.13.so: undefined reference to `mi_atomic_yield' collect2: error: ld returned 1 exit status make[1]: *** [Makefile:1024: python] Error 1 ``` The quick fix may be as simple as changing the `__ARM_ARCH__` -> `__ARM_ARCH` macro reference, but I'm waiting on input from upstream --- Workarounds: disable mimalloc ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131784 * gh-131954 <!-- /gh-linked-prs -->
03f6c8e239723637811fd8d278661f5292351197
0cd4befb02df07c0b320cd6246227c13e57b2efb
python/cpython
python__cpython-131682
# `anext(A(), default)` crashes when `StopAsyncIteration` is raised by a synchronous `__anext__` # Crash report ### What happened? ```py Python 3.14.0a6+ (heads/main:0e53038ea82, Mar 24 2025, 14:56:34) [GCC 7.5.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> class A: ... def __anext__(self): ... raise StopAsyncIteration ... >>> anext(A(), "a") Segmentation fault (core dumped) ``` There is no crash with `anext(A())` or when directly calling `__anext__()`. Or when `__anext__` is declared with `async def`, it's fine. Or when `__anext__()` doesn't raise, it's also fine. NB: I haven't bisected the change but it *might* be related to what I wrote in 76ffaef729c91bb79da6df2ade48f3ec51118300. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ ### Output from running 'python -VV' on the command line: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131682 * gh-131686 * gh-131687 <!-- /gh-linked-prs -->
929afd1d6ee4fb89ac818037effe6577947103de
5fef4ff9ed47e82bce0696672eb2e4bd8953bb1e
python/cpython
python__cpython-131671
# `anextawaitable_close()` should be a `METH_NOARGS` not `METH_VARARGS` # Bug report ### Bug description: See https://github.com/python/cpython/pull/131609#discussion_r2009832215. We can backport it because a TypeError is already raised (it's not raised by `anext_awaitable.close`, but rather by `coroutine_wrapper`). ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131671 <!-- /gh-linked-prs -->
1393bd35485d9a8aa99ceb7389fece91bb3fdefa
c3b8d73208a25735b6355de73297a51e9c1306b3
python/cpython
python__cpython-131653
# Remove duplicated bits in `Lib/test/clinic.test.c` # Feature or enhancement ### Proposal: We have some duplicated bits in `Lib/test/clinic.test.c`. This file should only consist of clinic directives and no actual code as it's never compiled (it will never compile as we never implement the functions). We have some code that just duplicates what clinic actually does. ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131653 <!-- /gh-linked-prs -->
9888f175de5a942c76aec7fb11fae7ede367997b
ecd03739f87889bb2f173e0a476d26b468c776c9
python/cpython
python__cpython-131650
# SyntaxWarning in test_string_literals # Bug report ### Bug description: ``` ./python -m unittest test.test_string_literals -vvv /home/graingert/projects/cpython/Lib/test/test_string_literals.py:180: SyntaxWarning: "\ " is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\ "? A raw string is also an option. eval("\"'''''''''''''''''''''invalid\ Escape\"") /home/graingert/projects/cpython/Lib/test/test_string_literals.py:191: SyntaxWarning: "\ " is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\ "? A raw string is also an option. eval("\"''Incorrect \ logic?\"") test_eval_bytes_incomplete (test.test_string_literals.TestLiterals.test_eval_bytes_incomplete) ... ok test_eval_bytes_invalid_escape (test.test_string_literals.TestLiterals.test_eval_bytes_invalid_escape) ... ok test_eval_bytes_invalid_octal_escape (test.test_string_literals.TestLiterals.test_eval_bytes_invalid_octal_escape) ... ok test_eval_bytes_normal (test.test_string_literals.TestLiterals.test_eval_bytes_normal) ... ok test_eval_bytes_raw (test.test_string_literals.TestLiterals.test_eval_bytes_raw) ... ok test_eval_str_incomplete (test.test_string_literals.TestLiterals.test_eval_str_incomplete) ... ok test_eval_str_invalid_escape (test.test_string_literals.TestLiterals.test_eval_str_invalid_escape) ... ok test_eval_str_invalid_octal_escape (test.test_string_literals.TestLiterals.test_eval_str_invalid_octal_escape) ... ok test_eval_str_normal (test.test_string_literals.TestLiterals.test_eval_str_normal) ... ok test_eval_str_raw (test.test_string_literals.TestLiterals.test_eval_str_raw) ... ok test_eval_str_u (test.test_string_literals.TestLiterals.test_eval_str_u) ... ok test_file_iso_8859_1 (test.test_string_literals.TestLiterals.test_file_iso_8859_1) ... ok test_file_latin9 (test.test_string_literals.TestLiterals.test_file_latin9) ... ok test_file_latin_1 (test.test_string_literals.TestLiterals.test_file_latin_1) ... ok test_file_utf8 (test.test_string_literals.TestLiterals.test_file_utf8) ... ok test_file_utf_8 (test.test_string_literals.TestLiterals.test_file_utf_8) ... ok test_file_utf_8_error (test.test_string_literals.TestLiterals.test_file_utf_8_error) ... ok test_invalid_escape_locations_with_offset (test.test_string_literals.TestLiterals.test_invalid_escape_locations_with_offset) ... ok test_template (test.test_string_literals.TestLiterals.test_template) ... ok test_uppercase_prefixes (test.test_string_literals.TestLiterals.test_uppercase_prefixes) ... ok ``` ### CPython versions tested on: 3.12, 3.13, 3.14, CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131650 * gh-131766 * gh-131772 <!-- /gh-linked-prs -->
2d83891dfd51f595de68b0336b3bfc876f7b2507
5abff6960b4aecb0d5c81c7482cf3faa74e1983d
python/cpython
python__cpython-131648
# ImportWarning in test_importlib ... test_permission_error_cwd # Bug report ### Bug description: ``` test_permission_error_cwd (test.test_importlib.import_.test_path.Source_FindModuleTests.test_permission_error_cwd) ... /home/graingert/projects/cpython/Lib/importlib/_bootstrap_external.py:1227: ImportWarning: sys.path_hooks is empty _warnings.warn('sys.path_hooks is empty', ImportWarning) ok ``` ### CPython versions tested on: 3.14, CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131648 <!-- /gh-linked-prs -->
8ada7a9e1435302ec2cb73375122072d0e1cdd6f
ea0453ee979174d6fc14aae0fd85e4ede6742a86
python/cpython
python__cpython-131646
# ResourceWarning(s) from test_asyncio.test_events.TestPyGetEventLoop.test_get_event_loop_new_process # Bug report ### Bug description: ``` PYTHONTRACEMALLOC=25 ./python -m unittest test.test_asyncio.test_events -vvv test_not_implemented (test.test_asyncio.test_events.AbstractEventLoopTests.test_not_implemented) ... ok test_not_implemented_async (test.test_asyncio.test_events.AbstractEventLoopTests.test_not_implemented_async) ... ok test_add_fds_after_closing (test.test_asyncio.test_events.EPollEventLoopTests.test_add_fds_after_closing) ... ok test_add_signal_handler (test.test_asyncio.test_events.EPollEventLoopTests.test_add_signal_handler) ... ok test_bidirectional_pty (test.test_asyncio.test_events.EPollEventLoopTests.test_bidirectional_pty) ... ok test_call_later (test.test_asyncio.test_events.EPollEventLoopTests.test_call_later) ... ok test_call_soon (test.test_asyncio.test_events.EPollEventLoopTests.test_call_soon) ... ok test_call_soon_threadsafe (test.test_asyncio.test_events.EPollEventLoopTests.test_call_soon_threadsafe) ... ok test_call_soon_threadsafe_handle_block_cancellation (test.test_asyncio.test_events.EPollEventLoopTests.test_call_soon_threadsafe_handle_block_cancellation) ... ok test_call_soon_threadsafe_handle_block_check_cancelled (test.test_asyncio.test_events.EPollEventLoopTests.test_call_soon_threadsafe_handle_block_check_cancelled) ... ok test_call_soon_threadsafe_handle_cancel_other_thread (test.test_asyncio.test_events.EPollEventLoopTests.test_call_soon_threadsafe_handle_cancel_other_thread) ... ok test_call_soon_threadsafe_handle_cancel_same_thread (test.test_asyncio.test_events.EPollEventLoopTests.test_call_soon_threadsafe_handle_cancel_same_thread) ... ok test_call_soon_threadsafe_same_thread (test.test_asyncio.test_events.EPollEventLoopTests.test_call_soon_threadsafe_same_thread) ... ok test_close (test.test_asyncio.test_events.EPollEventLoopTests.test_close) ... ok test_close_running_event_loop (test.test_asyncio.test_events.EPollEventLoopTests.test_close_running_event_loop) ... ok test_connect_accepted_socket (test.test_asyncio.test_events.EPollEventLoopTests.test_connect_accepted_socket) ... ok test_connect_accepted_socket_ssl_timeout_for_plain_socket (test.test_asyncio.test_events.EPollEventLoopTests.test_connect_accepted_socket_ssl_timeout_for_plain_socket) ... ok test_create_connection (test.test_asyncio.test_events.EPollEventLoopTests.test_create_connection) ... ok test_create_connection_local_addr (test.test_asyncio.test_events.EPollEventLoopTests.test_create_connection_local_addr) ... ok test_create_connection_local_addr_in_use (test.test_asyncio.test_events.EPollEventLoopTests.test_create_connection_local_addr_in_use) ... ok test_create_connection_local_addr_nomatch_family (test.test_asyncio.test_events.EPollEventLoopTests.test_create_connection_local_addr_nomatch_family) ... ok test_create_connection_local_addr_skip_different_family (test.test_asyncio.test_events.EPollEventLoopTests.test_create_connection_local_addr_skip_different_family) ... ok test_create_datagram_endpoint (test.test_asyncio.test_events.EPollEventLoopTests.test_create_datagram_endpoint) ... ok test_create_datagram_endpoint_ipv6 (test.test_asyncio.test_events.EPollEventLoopTests.test_create_datagram_endpoint_ipv6) ... ok test_create_datagram_endpoint_sock (test.test_asyncio.test_events.EPollEventLoopTests.test_create_datagram_endpoint_sock) ... ok test_create_server (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server) ... ok test_create_server_addr_in_use (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_addr_in_use) ... ok test_create_server_dual_stack (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_dual_stack) ... ok test_create_server_multiple_hosts_ipv4 (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_multiple_hosts_ipv4) ... ok test_create_server_multiple_hosts_ipv6 (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_multiple_hosts_ipv6) ... ok test_create_server_reuse_port (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_reuse_port) ... ok test_create_server_sock (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_sock) ... ok test_create_server_ssl (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_ssl) ... ok test_create_server_ssl_match_failed (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_ssl_match_failed) ... ok test_create_server_ssl_verified (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_ssl_verified) ... ok test_create_server_ssl_verify_failed (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_ssl_verify_failed) ... ok test_create_server_trsock (test.test_asyncio.test_events.EPollEventLoopTests.test_create_server_trsock) ... ok test_create_ssl_connection (test.test_asyncio.test_events.EPollEventLoopTests.test_create_ssl_connection) ... ok test_create_ssl_unix_connection (test.test_asyncio.test_events.EPollEventLoopTests.test_create_ssl_unix_connection) ... ok test_create_unix_connection (test.test_asyncio.test_events.EPollEventLoopTests.test_create_unix_connection) ... ok test_create_unix_server (test.test_asyncio.test_events.EPollEventLoopTests.test_create_unix_server) ... ok test_create_unix_server_path_socket_error (test.test_asyncio.test_events.EPollEventLoopTests.test_create_unix_server_path_socket_error) ... ok test_create_unix_server_ssl (test.test_asyncio.test_events.EPollEventLoopTests.test_create_unix_server_ssl) ... ok test_create_unix_server_ssl_verified (test.test_asyncio.test_events.EPollEventLoopTests.test_create_unix_server_ssl_verified) ... ok test_create_unix_server_ssl_verify_failed (test.test_asyncio.test_events.EPollEventLoopTests.test_create_unix_server_ssl_verify_failed) ... ok test_datagram_send_to_non_listening_address (test.test_asyncio.test_events.EPollEventLoopTests.test_datagram_send_to_non_listening_address) ... ok test_internal_fds (test.test_asyncio.test_events.EPollEventLoopTests.test_internal_fds) ... ok test_prompt_cancellation (test.test_asyncio.test_events.EPollEventLoopTests.test_prompt_cancellation) ... ok test_read_pipe (test.test_asyncio.test_events.EPollEventLoopTests.test_read_pipe) ... ok test_read_pty_output (test.test_asyncio.test_events.EPollEventLoopTests.test_read_pty_output) ... ok test_reader_callback (test.test_asyncio.test_events.EPollEventLoopTests.test_reader_callback) ... ok test_remove_fds_after_closing (test.test_asyncio.test_events.EPollEventLoopTests.test_remove_fds_after_closing) ... ok test_run_in_executor (test.test_asyncio.test_events.EPollEventLoopTests.test_run_in_executor) ... ok test_run_in_executor_cancel (test.test_asyncio.test_events.EPollEventLoopTests.test_run_in_executor_cancel) ... ok test_run_until_complete (test.test_asyncio.test_events.EPollEventLoopTests.test_run_until_complete) ... ok test_run_until_complete_nesting (test.test_asyncio.test_events.EPollEventLoopTests.test_run_until_complete_nesting) ... ok test_run_until_complete_stopped (test.test_asyncio.test_events.EPollEventLoopTests.test_run_until_complete_stopped) ... ok test_server_close (test.test_asyncio.test_events.EPollEventLoopTests.test_server_close) ... ok test_signal_handling_args (test.test_asyncio.test_events.EPollEventLoopTests.test_signal_handling_args) ... ok test_signal_handling_while_selecting (test.test_asyncio.test_events.EPollEventLoopTests.test_signal_handling_while_selecting) ... ok test_ssl_connect_accepted_socket (test.test_asyncio.test_events.EPollEventLoopTests.test_ssl_connect_accepted_socket) ... ok test_subprocess_close_after_finish (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_close_after_finish) ... ok test_subprocess_close_client_stream (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_close_client_stream) ... ok test_subprocess_exec (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_exec) ... ok test_subprocess_exec_invalid_args (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_exec_invalid_args) ... ok test_subprocess_exitcode (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_exitcode) ... ok test_subprocess_interactive (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_interactive) ... ok test_subprocess_kill (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_kill) ... ok test_subprocess_send_signal (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_send_signal) ... ok test_subprocess_shell (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_shell) ... ok test_subprocess_shell_invalid_args (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_shell_invalid_args) ... ok test_subprocess_stderr (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_stderr) ... ok test_subprocess_stderr_redirect_to_stdout (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_stderr_redirect_to_stdout) ... ok test_subprocess_terminate (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_terminate) ... ok test_subprocess_wait_no_same_group (test.test_asyncio.test_events.EPollEventLoopTests.test_subprocess_wait_no_same_group) ... ok test_timeout_rounding (test.test_asyncio.test_events.EPollEventLoopTests.test_timeout_rounding) ... ok test_unclosed_pipe_transport (test.test_asyncio.test_events.EPollEventLoopTests.test_unclosed_pipe_transport) ... ok test_write_pipe (test.test_asyncio.test_events.EPollEventLoopTests.test_write_pipe) ... ok test_write_pipe_disconnect_on_close (test.test_asyncio.test_events.EPollEventLoopTests.test_write_pipe_disconnect_on_close) ... ok test_write_pty (test.test_asyncio.test_events.EPollEventLoopTests.test_write_pty) ... ok test_writer_callback (test.test_asyncio.test_events.EPollEventLoopTests.test_writer_callback) ... ok test_callback_with_exception (test.test_asyncio.test_events.HandleTests.test_callback_with_exception) ... ok test_coroutine_like_object_debug_formatting (test.test_asyncio.test_events.HandleTests.test_coroutine_like_object_debug_formatting) ... ok test_handle (test.test_asyncio.test_events.HandleTests.test_handle) ... ok test_handle_repr (test.test_asyncio.test_events.HandleTests.test_handle_repr) ... ok test_handle_repr_debug (test.test_asyncio.test_events.HandleTests.test_handle_repr_debug) ... ok test_handle_source_traceback (test.test_asyncio.test_events.HandleTests.test_handle_source_traceback) ... ok test_handle_weakref (test.test_asyncio.test_events.HandleTests.test_handle_weakref) ... ok test_abstract_event_loop_policy_deprecation (test.test_asyncio.test_events.PolicyTests.test_abstract_event_loop_policy_deprecation) ... ok test_asyncio_set_event_loop_deprecation (test.test_asyncio.test_events.PolicyTests.test_asyncio_set_event_loop_deprecation) ... ok test_default_event_loop_policy_deprecation (test.test_asyncio.test_events.PolicyTests.test_default_event_loop_policy_deprecation) ... ok test_event_loop_policy (test.test_asyncio.test_events.PolicyTests.test_event_loop_policy) ... ok test_get_event_loop (test.test_asyncio.test_events.PolicyTests.test_get_event_loop) ... ok test_get_event_loop_after_set_none (test.test_asyncio.test_events.PolicyTests.test_get_event_loop_after_set_none) ... ok test_get_event_loop_does_not_call_set_event_loop (test.test_asyncio.test_events.PolicyTests.test_get_event_loop_does_not_call_set_event_loop) ... ok test_get_event_loop_policy (test.test_asyncio.test_events.PolicyTests.test_get_event_loop_policy) ... ok test_get_event_loop_thread (test.test_asyncio.test_events.PolicyTests.test_get_event_loop_thread) ... ok test_new_event_loop (test.test_asyncio.test_events.PolicyTests.test_new_event_loop) ... ok test_set_event_loop (test.test_asyncio.test_events.PolicyTests.test_set_event_loop) ... ok test_set_event_loop_policy (test.test_asyncio.test_events.PolicyTests.test_set_event_loop_policy) ... ok test_add_fds_after_closing (test.test_asyncio.test_events.PollEventLoopTests.test_add_fds_after_closing) ... ok test_add_signal_handler (test.test_asyncio.test_events.PollEventLoopTests.test_add_signal_handler) ... ok test_bidirectional_pty (test.test_asyncio.test_events.PollEventLoopTests.test_bidirectional_pty) ... ok test_call_later (test.test_asyncio.test_events.PollEventLoopTests.test_call_later) ... ok test_call_soon (test.test_asyncio.test_events.PollEventLoopTests.test_call_soon) ... ok test_call_soon_threadsafe (test.test_asyncio.test_events.PollEventLoopTests.test_call_soon_threadsafe) ... ok test_call_soon_threadsafe_handle_block_cancellation (test.test_asyncio.test_events.PollEventLoopTests.test_call_soon_threadsafe_handle_block_cancellation) ... ok test_call_soon_threadsafe_handle_block_check_cancelled (test.test_asyncio.test_events.PollEventLoopTests.test_call_soon_threadsafe_handle_block_check_cancelled) ... ok test_call_soon_threadsafe_handle_cancel_other_thread (test.test_asyncio.test_events.PollEventLoopTests.test_call_soon_threadsafe_handle_cancel_other_thread) ... ok test_call_soon_threadsafe_handle_cancel_same_thread (test.test_asyncio.test_events.PollEventLoopTests.test_call_soon_threadsafe_handle_cancel_same_thread) ... ok test_call_soon_threadsafe_same_thread (test.test_asyncio.test_events.PollEventLoopTests.test_call_soon_threadsafe_same_thread) ... ok test_close (test.test_asyncio.test_events.PollEventLoopTests.test_close) ... ok test_close_running_event_loop (test.test_asyncio.test_events.PollEventLoopTests.test_close_running_event_loop) ... ok test_connect_accepted_socket (test.test_asyncio.test_events.PollEventLoopTests.test_connect_accepted_socket) ... ok test_connect_accepted_socket_ssl_timeout_for_plain_socket (test.test_asyncio.test_events.PollEventLoopTests.test_connect_accepted_socket_ssl_timeout_for_plain_socket) ... ok test_create_connection (test.test_asyncio.test_events.PollEventLoopTests.test_create_connection) ... ok test_create_connection_local_addr (test.test_asyncio.test_events.PollEventLoopTests.test_create_connection_local_addr) ... ok test_create_connection_local_addr_in_use (test.test_asyncio.test_events.PollEventLoopTests.test_create_connection_local_addr_in_use) ... ok test_create_connection_local_addr_nomatch_family (test.test_asyncio.test_events.PollEventLoopTests.test_create_connection_local_addr_nomatch_family) ... ok test_create_connection_local_addr_skip_different_family (test.test_asyncio.test_events.PollEventLoopTests.test_create_connection_local_addr_skip_different_family) ... ok test_create_datagram_endpoint (test.test_asyncio.test_events.PollEventLoopTests.test_create_datagram_endpoint) ... ok test_create_datagram_endpoint_ipv6 (test.test_asyncio.test_events.PollEventLoopTests.test_create_datagram_endpoint_ipv6) ... ok test_create_datagram_endpoint_sock (test.test_asyncio.test_events.PollEventLoopTests.test_create_datagram_endpoint_sock) ... ok test_create_server (test.test_asyncio.test_events.PollEventLoopTests.test_create_server) ... ok test_create_server_addr_in_use (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_addr_in_use) ... ok test_create_server_dual_stack (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_dual_stack) ... ok test_create_server_multiple_hosts_ipv4 (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_multiple_hosts_ipv4) ... ok test_create_server_multiple_hosts_ipv6 (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_multiple_hosts_ipv6) ... ok test_create_server_reuse_port (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_reuse_port) ... ok test_create_server_sock (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_sock) ... ok test_create_server_ssl (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_ssl) ... ok test_create_server_ssl_match_failed (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_ssl_match_failed) ... ok test_create_server_ssl_verified (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_ssl_verified) ... ok test_create_server_ssl_verify_failed (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_ssl_verify_failed) ... ok test_create_server_trsock (test.test_asyncio.test_events.PollEventLoopTests.test_create_server_trsock) ... ok test_create_ssl_connection (test.test_asyncio.test_events.PollEventLoopTests.test_create_ssl_connection) ... ok test_create_ssl_unix_connection (test.test_asyncio.test_events.PollEventLoopTests.test_create_ssl_unix_connection) ... ok test_create_unix_connection (test.test_asyncio.test_events.PollEventLoopTests.test_create_unix_connection) ... ok test_create_unix_server (test.test_asyncio.test_events.PollEventLoopTests.test_create_unix_server) ... ok test_create_unix_server_path_socket_error (test.test_asyncio.test_events.PollEventLoopTests.test_create_unix_server_path_socket_error) ... ok test_create_unix_server_ssl (test.test_asyncio.test_events.PollEventLoopTests.test_create_unix_server_ssl) ... ok test_create_unix_server_ssl_verified (test.test_asyncio.test_events.PollEventLoopTests.test_create_unix_server_ssl_verified) ... ok test_create_unix_server_ssl_verify_failed (test.test_asyncio.test_events.PollEventLoopTests.test_create_unix_server_ssl_verify_failed) ... ok test_datagram_send_to_non_listening_address (test.test_asyncio.test_events.PollEventLoopTests.test_datagram_send_to_non_listening_address) ... ok test_internal_fds (test.test_asyncio.test_events.PollEventLoopTests.test_internal_fds) ... ok test_prompt_cancellation (test.test_asyncio.test_events.PollEventLoopTests.test_prompt_cancellation) ... ok test_read_pipe (test.test_asyncio.test_events.PollEventLoopTests.test_read_pipe) ... ok test_read_pty_output (test.test_asyncio.test_events.PollEventLoopTests.test_read_pty_output) ... ok test_reader_callback (test.test_asyncio.test_events.PollEventLoopTests.test_reader_callback) ... ok test_remove_fds_after_closing (test.test_asyncio.test_events.PollEventLoopTests.test_remove_fds_after_closing) ... ok test_run_in_executor (test.test_asyncio.test_events.PollEventLoopTests.test_run_in_executor) ... ok test_run_in_executor_cancel (test.test_asyncio.test_events.PollEventLoopTests.test_run_in_executor_cancel) ... ok test_run_until_complete (test.test_asyncio.test_events.PollEventLoopTests.test_run_until_complete) ... ok test_run_until_complete_nesting (test.test_asyncio.test_events.PollEventLoopTests.test_run_until_complete_nesting) ... ok test_run_until_complete_stopped (test.test_asyncio.test_events.PollEventLoopTests.test_run_until_complete_stopped) ... ok test_server_close (test.test_asyncio.test_events.PollEventLoopTests.test_server_close) ... ok test_signal_handling_args (test.test_asyncio.test_events.PollEventLoopTests.test_signal_handling_args) ... ok test_signal_handling_while_selecting (test.test_asyncio.test_events.PollEventLoopTests.test_signal_handling_while_selecting) ... ok test_ssl_connect_accepted_socket (test.test_asyncio.test_events.PollEventLoopTests.test_ssl_connect_accepted_socket) ... ok test_subprocess_close_after_finish (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_close_after_finish) ... ok test_subprocess_close_client_stream (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_close_client_stream) ... ok test_subprocess_exec (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_exec) ... ok test_subprocess_exec_invalid_args (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_exec_invalid_args) ... ok test_subprocess_exitcode (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_exitcode) ... ok test_subprocess_interactive (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_interactive) ... ok test_subprocess_kill (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_kill) ... ok test_subprocess_send_signal (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_send_signal) ... ok test_subprocess_shell (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_shell) ... ok test_subprocess_shell_invalid_args (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_shell_invalid_args) ... ok test_subprocess_stderr (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_stderr) ... ok test_subprocess_stderr_redirect_to_stdout (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_stderr_redirect_to_stdout) ... ok test_subprocess_terminate (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_terminate) ... ok test_subprocess_wait_no_same_group (test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_wait_no_same_group) ... ok test_timeout_rounding (test.test_asyncio.test_events.PollEventLoopTests.test_timeout_rounding) ... ok test_unclosed_pipe_transport (test.test_asyncio.test_events.PollEventLoopTests.test_unclosed_pipe_transport) ... ok test_write_pipe (test.test_asyncio.test_events.PollEventLoopTests.test_write_pipe) ... ok test_write_pipe_disconnect_on_close (test.test_asyncio.test_events.PollEventLoopTests.test_write_pipe_disconnect_on_close) ... ok test_write_pty (test.test_asyncio.test_events.PollEventLoopTests.test_write_pty) ... ok test_writer_callback (test.test_asyncio.test_events.PollEventLoopTests.test_writer_callback) ... ok test_add_fds_after_closing (test.test_asyncio.test_events.SelectEventLoopTests.test_add_fds_after_closing) ... ok test_add_signal_handler (test.test_asyncio.test_events.SelectEventLoopTests.test_add_signal_handler) ... ok test_bidirectional_pty (test.test_asyncio.test_events.SelectEventLoopTests.test_bidirectional_pty) ... ok test_call_later (test.test_asyncio.test_events.SelectEventLoopTests.test_call_later) ... ok test_call_soon (test.test_asyncio.test_events.SelectEventLoopTests.test_call_soon) ... ok test_call_soon_threadsafe (test.test_asyncio.test_events.SelectEventLoopTests.test_call_soon_threadsafe) ... ok test_call_soon_threadsafe_handle_block_cancellation (test.test_asyncio.test_events.SelectEventLoopTests.test_call_soon_threadsafe_handle_block_cancellation) ... ok test_call_soon_threadsafe_handle_block_check_cancelled (test.test_asyncio.test_events.SelectEventLoopTests.test_call_soon_threadsafe_handle_block_check_cancelled) ... ok test_call_soon_threadsafe_handle_cancel_other_thread (test.test_asyncio.test_events.SelectEventLoopTests.test_call_soon_threadsafe_handle_cancel_other_thread) ... ok test_call_soon_threadsafe_handle_cancel_same_thread (test.test_asyncio.test_events.SelectEventLoopTests.test_call_soon_threadsafe_handle_cancel_same_thread) ... ok test_call_soon_threadsafe_same_thread (test.test_asyncio.test_events.SelectEventLoopTests.test_call_soon_threadsafe_same_thread) ... ok test_close (test.test_asyncio.test_events.SelectEventLoopTests.test_close) ... ok test_close_running_event_loop (test.test_asyncio.test_events.SelectEventLoopTests.test_close_running_event_loop) ... ok test_connect_accepted_socket (test.test_asyncio.test_events.SelectEventLoopTests.test_connect_accepted_socket) ... ok test_connect_accepted_socket_ssl_timeout_for_plain_socket (test.test_asyncio.test_events.SelectEventLoopTests.test_connect_accepted_socket_ssl_timeout_for_plain_socket) ... ok test_create_connection (test.test_asyncio.test_events.SelectEventLoopTests.test_create_connection) ... ok test_create_connection_local_addr (test.test_asyncio.test_events.SelectEventLoopTests.test_create_connection_local_addr) ... ok test_create_connection_local_addr_in_use (test.test_asyncio.test_events.SelectEventLoopTests.test_create_connection_local_addr_in_use) ... ok test_create_connection_local_addr_nomatch_family (test.test_asyncio.test_events.SelectEventLoopTests.test_create_connection_local_addr_nomatch_family) ... ok test_create_connection_local_addr_skip_different_family (test.test_asyncio.test_events.SelectEventLoopTests.test_create_connection_local_addr_skip_different_family) ... ok test_create_datagram_endpoint (test.test_asyncio.test_events.SelectEventLoopTests.test_create_datagram_endpoint) ... ok test_create_datagram_endpoint_ipv6 (test.test_asyncio.test_events.SelectEventLoopTests.test_create_datagram_endpoint_ipv6) ... ok test_create_datagram_endpoint_sock (test.test_asyncio.test_events.SelectEventLoopTests.test_create_datagram_endpoint_sock) ... ok test_create_server (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server) ... ok test_create_server_addr_in_use (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_addr_in_use) ... ok test_create_server_dual_stack (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_dual_stack) ... ok test_create_server_multiple_hosts_ipv4 (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_multiple_hosts_ipv4) ... ok test_create_server_multiple_hosts_ipv6 (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_multiple_hosts_ipv6) ... ok test_create_server_reuse_port (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_reuse_port) ... ok test_create_server_sock (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_sock) ... ok test_create_server_ssl (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_ssl) ... ok test_create_server_ssl_match_failed (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_ssl_match_failed) ... ok test_create_server_ssl_verified (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_ssl_verified) ... ok test_create_server_ssl_verify_failed (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_ssl_verify_failed) ... ok test_create_server_trsock (test.test_asyncio.test_events.SelectEventLoopTests.test_create_server_trsock) ... ok test_create_ssl_connection (test.test_asyncio.test_events.SelectEventLoopTests.test_create_ssl_connection) ... ok test_create_ssl_unix_connection (test.test_asyncio.test_events.SelectEventLoopTests.test_create_ssl_unix_connection) ... ok test_create_unix_connection (test.test_asyncio.test_events.SelectEventLoopTests.test_create_unix_connection) ... ok test_create_unix_server (test.test_asyncio.test_events.SelectEventLoopTests.test_create_unix_server) ... ok test_create_unix_server_path_socket_error (test.test_asyncio.test_events.SelectEventLoopTests.test_create_unix_server_path_socket_error) ... ok test_create_unix_server_ssl (test.test_asyncio.test_events.SelectEventLoopTests.test_create_unix_server_ssl) ... ok test_create_unix_server_ssl_verified (test.test_asyncio.test_events.SelectEventLoopTests.test_create_unix_server_ssl_verified) ... ok test_create_unix_server_ssl_verify_failed (test.test_asyncio.test_events.SelectEventLoopTests.test_create_unix_server_ssl_verify_failed) ... ok test_datagram_send_to_non_listening_address (test.test_asyncio.test_events.SelectEventLoopTests.test_datagram_send_to_non_listening_address) ... ok test_internal_fds (test.test_asyncio.test_events.SelectEventLoopTests.test_internal_fds) ... ok test_prompt_cancellation (test.test_asyncio.test_events.SelectEventLoopTests.test_prompt_cancellation) ... ok test_read_pipe (test.test_asyncio.test_events.SelectEventLoopTests.test_read_pipe) ... ok test_read_pty_output (test.test_asyncio.test_events.SelectEventLoopTests.test_read_pty_output) ... ok test_reader_callback (test.test_asyncio.test_events.SelectEventLoopTests.test_reader_callback) ... ok test_remove_fds_after_closing (test.test_asyncio.test_events.SelectEventLoopTests.test_remove_fds_after_closing) ... ok test_run_in_executor (test.test_asyncio.test_events.SelectEventLoopTests.test_run_in_executor) ... ok test_run_in_executor_cancel (test.test_asyncio.test_events.SelectEventLoopTests.test_run_in_executor_cancel) ... ok test_run_until_complete (test.test_asyncio.test_events.SelectEventLoopTests.test_run_until_complete) ... ok test_run_until_complete_nesting (test.test_asyncio.test_events.SelectEventLoopTests.test_run_until_complete_nesting) ... ok test_run_until_complete_stopped (test.test_asyncio.test_events.SelectEventLoopTests.test_run_until_complete_stopped) ... ok test_server_close (test.test_asyncio.test_events.SelectEventLoopTests.test_server_close) ... ok test_signal_handling_args (test.test_asyncio.test_events.SelectEventLoopTests.test_signal_handling_args) ... ok test_signal_handling_while_selecting (test.test_asyncio.test_events.SelectEventLoopTests.test_signal_handling_while_selecting) ... ok test_ssl_connect_accepted_socket (test.test_asyncio.test_events.SelectEventLoopTests.test_ssl_connect_accepted_socket) ... ok test_subprocess_close_after_finish (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_close_after_finish) ... ok test_subprocess_close_client_stream (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_close_client_stream) ... ok test_subprocess_exec (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_exec) ... ok test_subprocess_exec_invalid_args (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_exec_invalid_args) ... ok test_subprocess_exitcode (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_exitcode) ... ok test_subprocess_interactive (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_interactive) ... ok test_subprocess_kill (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_kill) ... ok test_subprocess_send_signal (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_send_signal) ... ok test_subprocess_shell (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_shell) ... ok test_subprocess_shell_invalid_args (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_shell_invalid_args) ... ok test_subprocess_stderr (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_stderr) ... ok test_subprocess_stderr_redirect_to_stdout (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_stderr_redirect_to_stdout) ... ok test_subprocess_terminate (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_terminate) ... ok test_subprocess_wait_no_same_group (test.test_asyncio.test_events.SelectEventLoopTests.test_subprocess_wait_no_same_group) ... ok test_timeout_rounding (test.test_asyncio.test_events.SelectEventLoopTests.test_timeout_rounding) ... ok test_unclosed_pipe_transport (test.test_asyncio.test_events.SelectEventLoopTests.test_unclosed_pipe_transport) ... ok test_write_pipe (test.test_asyncio.test_events.SelectEventLoopTests.test_write_pipe) ... ok test_write_pipe_disconnect_on_close (test.test_asyncio.test_events.SelectEventLoopTests.test_write_pipe_disconnect_on_close) ... ok test_write_pty (test.test_asyncio.test_events.SelectEventLoopTests.test_write_pty) ... ok test_writer_callback (test.test_asyncio.test_events.SelectEventLoopTests.test_writer_callback) ... ok test_close (test.test_asyncio.test_events.TestAbstractServer.test_close) ... ok test_get_loop (test.test_asyncio.test_events.TestAbstractServer.test_get_loop) ... ok test_wait_closed (test.test_asyncio.test_events.TestAbstractServer.test_wait_closed) ... ok test_get_event_loop_new_process (test.test_asyncio.test_events.TestCGetEventLoop.test_get_event_loop_new_process) ... ok test_get_event_loop_returns_running_loop (test.test_asyncio.test_events.TestCGetEventLoop.test_get_event_loop_returns_running_loop) ... ok test_get_event_loop_returns_running_loop2 (test.test_asyncio.test_events.TestCGetEventLoop.test_get_event_loop_returns_running_loop2) ... ok test_get_running_loop_already_running (test.test_asyncio.test_events.TestCGetEventLoop.test_get_running_loop_already_running) ... ok test_get_event_loop_new_process (test.test_asyncio.test_events.TestPyGetEventLoop.test_get_event_loop_new_process) ... /home/graingert/projects/cpython/Lib/asyncio/base_events.py:758: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False> _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self) Object allocated at (most recent call last): File "<frozen runpy>", lineno 198 File "<frozen runpy>", lineno 88 File "/home/graingert/projects/cpython/Lib/unittest/__main__.py", lineno 18 main(module=None) File "/home/graingert/projects/cpython/Lib/unittest/main.py", lineno 104 self.runTests() File "/home/graingert/projects/cpython/Lib/unittest/main.py", lineno 270 self.result = testRunner.run(self.test) File "/home/graingert/projects/cpython/Lib/unittest/runner.py", lineno 259 test(result) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 84 return self.run(*args, **kwds) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 122 test(result) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 84 return self.run(*args, **kwds) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 122 test(result) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 84 return self.run(*args, **kwds) File "/home/graingert/projects/cpython/Lib/unittest/suite.py", lineno 122 test(result) File "/home/graingert/projects/cpython/Lib/unittest/case.py", lineno 716 return self.run(*args, **kwds) File "/home/graingert/projects/cpython/Lib/unittest/case.py", lineno 660 self._callTestMethod(testMethod) File "/home/graingert/projects/cpython/Lib/unittest/case.py", lineno 606 result = method() File "/home/graingert/projects/cpython/Lib/test/test_asyncio/test_events.py", lineno 3018 self.loop.run_until_complete(main()) File "/home/graingert/projects/cpython/Lib/asyncio/base_events.py", lineno 706 self.run_forever() File "/home/graingert/projects/cpython/Lib/asyncio/base_events.py", lineno 677 self._run_once() File "/home/graingert/projects/cpython/Lib/asyncio/base_events.py", lineno 2037 handle._run() File "/home/graingert/projects/cpython/Lib/asyncio/events.py", lineno 98 self._context.run(self._callback, *self._args) File "/home/graingert/projects/cpython/Lib/test/test_asyncio/test_events.py", lineno 3008 loop = asyncio.new_event_loop() File "/home/graingert/projects/cpython/Lib/asyncio/events.py", lineno 849 return _get_event_loop_policy().new_event_loop() File "/home/graingert/projects/cpython/Lib/asyncio/events.py", lineno 736 return self._loop_factory() ok test_get_event_loop_returns_running_loop (test.test_asyncio.test_events.TestPyGetEventLoop.test_get_event_loop_returns_running_loop) ... ok test_get_event_loop_returns_running_loop2 (test.test_asyncio.test_events.TestPyGetEventLoop.test_get_event_loop_returns_running_loop2) ... ok test_get_running_loop_already_running (test.test_asyncio.test_events.TestPyGetEventLoop.test_get_running_loop_already_running) ... ok test_get_loop (test.test_asyncio.test_events.TestServer.test_get_loop) ... ok test_hash (test.test_asyncio.test_events.TimerTests.test_hash) ... ok test_timer (test.test_asyncio.test_events.TimerTests.test_timer) ... ok test_timer_comparison (test.test_asyncio.test_events.TimerTests.test_timer_comparison) ... ok test_timer_repr (test.test_asyncio.test_events.TimerTests.test_timer_repr) ... ok test_timer_repr_debug (test.test_asyncio.test_events.TimerTests.test_timer_repr_debug) ... ok test_when (test.test_asyncio.test_events.TimerTests.test_when) ... ok ---------------------------------------------------------------------- Ran 276 tests in 18.901s OK ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131646 * gh-131661 <!-- /gh-linked-prs -->
71ce4acb25eb640a4582904172d2bb9600983f4c
01ea4c77e51d6a36000da7da7bfb48c58591b225
python/cpython
python__cpython-131625
# posix_spawn and posix_spawnp tests failing on NetBSD with stack limit assertions # Bug report ### Bug description: Multiple tests in `test_posix` for `posix_spawn` and `posix_spawnp` functionality are failing on NetBSD with stack limit-related assertions in the spawned processes. All failing tests show child processes exiting with code -6 (SIGABRT). ### Environment CPython version: 3.14.0a6+ (heads/main:557d2d20d48, Mar 23 2025) Platform: NetBSD-10.0-amd64-x86_64-64bit-ELF little-endian Build Flags: `--with-debug` ### Tests ```sh ./python -m test test_posix -m TestPosixSpawn -m TestPosixSpawnP -v ``` Output: ```python ─./python -m test test_posix -m TestPosixSpawn -m TestPosixSpawnP -v == CPython 3.14.0a6+ (heads/main:557d2d20d48, Mar 23 2025, 15:29:59) [GCC 10.5.0] == NetBSD-10.0-amd64-x86_64-64bit-ELF little-endian == Python build: debug == cwd: /home/blue/cpython/build/test_python_worker_362æ == CPU count: 16 == encodings: locale=UTF-8 FS=utf-8 == resources: all test resources are disabled, use -u option to unskip tests Using random seed: 1713724710 0:00:00 load avg: 0.17 Run 1 test sequentially in a single process 0:00:00 load avg: 0.17 [1/1] test_posix test_bad_file_actions (test.test_posix.TestPosixSpawn.test_bad_file_actions) ... ok test_close_file (test.test_posix.TestPosixSpawn.test_close_file) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_dup2 (test.test_posix.TestPosixSpawn.test_dup2) ... ok test_empty_file_actions (test.test_posix.TestPosixSpawn.test_empty_file_actions) ... ok test_multiple_file_actions (test.test_posix.TestPosixSpawn.test_multiple_file_actions) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_no_such_executable (test.test_posix.TestPosixSpawn.test_no_such_executable) ... ok test_none_file_actions (test.test_posix.TestPosixSpawn.test_none_file_actions) ... ok test_open_file (test.test_posix.TestPosixSpawn.test_open_file) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_resetids (test.test_posix.TestPosixSpawn.test_resetids) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_resetids_explicit_default (test.test_posix.TestPosixSpawn.test_resetids_explicit_default) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_returns_pid (test.test_posix.TestPosixSpawn.test_returns_pid) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_setpgroup (test.test_posix.TestPosixSpawn.test_setpgroup) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_setpgroup_wrong_type (test.test_posix.TestPosixSpawn.test_setpgroup_wrong_type) ... ok test_setscheduler_only_param (test.test_posix.TestPosixSpawn.test_setscheduler_only_param) ... skipped 'bpo-34685: test can fail on BSD' test_setscheduler_with_policy (test.test_posix.TestPosixSpawn.test_setscheduler_with_policy) ... skipped 'bpo-34685: test can fail on BSD' test_setsid (test.test_posix.TestPosixSpawn.test_setsid) ... skipped "setsid is not supported: NotImplementedError('posix_spawn: setsid unavailable on this platform')" test_setsigdef (test.test_posix.TestPosixSpawn.test_setsigdef) ... ok test_setsigdef_wrong_type (test.test_posix.TestPosixSpawn.test_setsigdef_wrong_type) ... ok test_setsigmask (test.test_posix.TestPosixSpawn.test_setsigmask) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_setsigmask_wrong_type (test.test_posix.TestPosixSpawn.test_setsigmask_wrong_type) ... ok test_specify_environment (test.test_posix.TestPosixSpawn.test_specify_environment) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_bad_file_actions (test.test_posix.TestPosixSpawnP.test_bad_file_actions) ... ok test_close_file (test.test_posix.TestPosixSpawnP.test_close_file) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_dup2 (test.test_posix.TestPosixSpawnP.test_dup2) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_empty_file_actions (test.test_posix.TestPosixSpawnP.test_empty_file_actions) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_multiple_file_actions (test.test_posix.TestPosixSpawnP.test_multiple_file_actions) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_no_such_executable (test.test_posix.TestPosixSpawnP.test_no_such_executable) ... ok test_none_file_actions (test.test_posix.TestPosixSpawnP.test_none_file_actions) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_open_file (test.test_posix.TestPosixSpawnP.test_open_file) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL test_posix_spawnp (test.test_posix.TestPosixSpawnP.test_posix_spawnp) ... ok test_resetids (test.test_posix.TestPosixSpawnP.test_resetids) ... assertion "_tstate->c_stack_soft_limit < here_addr" failed: file "Python/ceval.c", line 467, function "_Py_InitializeRecursionLimits" FAIL test_resetids_explicit_default (test.test_posix.TestPosixSpawnP.test_resetids_explicit_default) ... assertion "_tstate->c_stack_soft_limit < here_addr" failed: file "Python/ceval.c", line 467, function "_Py_InitializeRecursionLimits" FAIL test_returns_pid (test.test_posix.TestPosixSpawnP.test_returns_pid) ... assertion "_tstate->c_stack_soft_limit < here_addr" failed: file "Python/ceval.c", line 467, function "_Py_InitializeRecursionLimits" FAIL test_setpgroup (test.test_posix.TestPosixSpawnP.test_setpgroup) ... assertion "_tstate->c_stack_soft_limit < here_addr" failed: file "Python/ceval.c", line 467, function "_Py_InitializeRecursionLimits" FAIL test_setpgroup_wrong_type (test.test_posix.TestPosixSpawnP.test_setpgroup_wrong_type) ... ok test_setscheduler_only_param (test.test_posix.TestPosixSpawnP.test_setscheduler_only_param) ... skipped 'bpo-34685: test can fail on BSD' test_setscheduler_with_policy (test.test_posix.TestPosixSpawnP.test_setscheduler_with_policy) ... skipped 'bpo-34685: test can fail on BSD' test_setsid (test.test_posix.TestPosixSpawnP.test_setsid) ... skipped "setsid is not supported: NotImplementedError('posix_spawnp: setsid unavailable on this platform')" test_setsigdef (test.test_posix.TestPosixSpawnP.test_setsigdef) ... assertion "_tstate->c_stack_soft_limit < here_addr" failed: file "Python/ceval.c", line 467, function "_Py_InitializeRecursionLimits" FAIL test_setsigdef_wrong_type (test.test_posix.TestPosixSpawnP.test_setsigdef_wrong_type) ... ok test_setsigmask (test.test_posix.TestPosixSpawnP.test_setsigmask) ... ok test_setsigmask_wrong_type (test.test_posix.TestPosixSpawnP.test_setsigmask_wrong_type) ... ok test_specify_environment (test.test_posix.TestPosixSpawnP.test_specify_environment) ... assertion "here_addr < _tstate->c_stack_top" failed: file "Python/ceval.c", line 468, function "_Py_InitializeRecursionLimits" FAIL ====================================================================== FAIL: test_close_file (test.test_posix.TestPosixSpawn.test_close_file) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 2087, in test_close_file support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 14888 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_multiple_file_actions (test.test_posix.TestPosixSpawn.test_multiple_file_actions) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 2021, in test_multiple_file_actions support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 4875 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_open_file (test.test_posix.TestPosixSpawn.test_open_file) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 2068, in test_open_file support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 22411 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_resetids (test.test_posix.TestPosixSpawn.test_resetids) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1860, in test_resetids support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 6982 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_resetids_explicit_default (test.test_posix.TestPosixSpawn.test_resetids_explicit_default) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1851, in test_resetids_explicit_default support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 9121 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_returns_pid (test.test_posix.TestPosixSpawn.test_returns_pid) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1792, in test_returns_pid support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 20376 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_setpgroup (test.test_posix.TestPosixSpawn.test_setpgroup) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1869, in test_setpgroup support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 29677 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_setsigmask (test.test_posix.TestPosixSpawn.test_setsigmask) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1890, in test_setsigmask support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 29091 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_specify_environment (test.test_posix.TestPosixSpawn.test_specify_environment) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1822, in test_specify_environment support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 26401 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_close_file (test.test_posix.TestPosixSpawnP.test_close_file) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 2087, in test_close_file support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 2519 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_dup2 (test.test_posix.TestPosixSpawnP.test_dup2) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 2105, in test_dup2 support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 10663 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_empty_file_actions (test.test_posix.TestPosixSpawnP.test_empty_file_actions) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1842, in test_empty_file_actions support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 29538 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_multiple_file_actions (test.test_posix.TestPosixSpawnP.test_multiple_file_actions) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 2021, in test_multiple_file_actions support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 13306 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_none_file_actions (test.test_posix.TestPosixSpawnP.test_none_file_actions) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1833, in test_none_file_actions support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 4660 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_open_file (test.test_posix.TestPosixSpawnP.test_open_file) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 2068, in test_open_file support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 15283 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_resetids (test.test_posix.TestPosixSpawnP.test_resetids) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1860, in test_resetids support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 27835 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_resetids_explicit_default (test.test_posix.TestPosixSpawnP.test_resetids_explicit_default) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1851, in test_resetids_explicit_default support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 12737 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_returns_pid (test.test_posix.TestPosixSpawnP.test_returns_pid) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1792, in test_returns_pid support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 1830 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_setpgroup (test.test_posix.TestPosixSpawnP.test_setpgroup) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1869, in test_setpgroup support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 24458 exited with code -6, but exit code 0 is expected ====================================================================== FAIL: test_setsigdef (test.test_posix.TestPosixSpawnP.test_setsigdef) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1955, in test_setsigdef support.wait_process(pid, exitcode=-signal.SIGUSR1) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 11736 exited with code -6, but exit code -30 is expected ====================================================================== FAIL: test_specify_environment (test.test_posix.TestPosixSpawnP.test_specify_environment) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_posix.py", line 1822, in test_specify_environment support.wait_process(pid, exitcode=0) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/support/__init__.py", line 2241, in wait_process raise AssertionError(f"process {pid} exited with code {exitcode2}, " f"but exit code {exitcode} is expected") AssertionError: process 28506 exited with code -6, but exit code 0 is expected ---------------------------------------------------------------------- Ran 43 tests in 2.545s FAILED (failures=21, skipped=6) Warning -- files was modified by test_posix Warning -- Before: [] Warning -- After: ['python.core'] test test_posix failed 0:00:02 load avg: 0.17 [1/1/1] test_posix failed (21 failures) == Tests result: FAILURE == 1 test failed: test_posix Total duration: 2.7 sec Total tests: run=43 (filtered) failures=21 skipped=6 Total test files: run=1/1 (filtered) failed=1 Result: FAILURE ``` ### CPython versions tested on: CPython main branch, 3.14 ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-131625 <!-- /gh-linked-prs -->
c7f6535e4a3b447fbd67bf98eea82fd243e780be
00cf5eacc52d4790c23a24c835fb6b048cb27d8c
python/cpython
python__cpython-131588
# Use stackrefs in `_PyType_LookupRef` and related functions # Feature or enhancement The [`object_lookup_special`](https://github.com/python/cpython/blob/56d0f9af147b2280ea0af7af5e57df1a01271991/Tools/ftscalingbench/ftscalingbench.py#L61-L66) microbenchmark in [`Tools/ftscalingbench/ftscalingbench.py`](https://github.com/python/cpython/blob/56d0f9af147b2280ea0af7af5e57df1a01271991/Tools/ftscalingbench/ftscalingbench.py) currently doesn't scale well and is indicative of a broader FT performance issue that we should fix. The benchmark just calls `round()` from multiple threads concurrently: https://github.com/python/cpython/blob/56d0f9af147b2280ea0af7af5e57df1a01271991/Tools/ftscalingbench/ftscalingbench.py#L62-L66 The issue is that `round()` calls `_PyObject_LookupSpecial(number, &_Py_ID(__round__))`, which increments the reference count of the returned function (i.e., of `float.round`). The underlying function supports deferred reference counting, but `_PyObject_LookupSpecial` and `_PyType_LookupRef` do not take advantage of it. For the FT build, we also need some extra support in order to safely use `_PyStackRef` in `builtin_round_impl`, because it's important that all `_PyStackRef`s are visible to the GC. To support this, we can add a singly linked list of active `_PyStackRef`s to `_PyThreadStateImpl`. The `struct _PyCStackRef` implements this linked list pointer + a `_PyStackRef`. In the GIL-enabled build, there's no linked list and it's essentially the same as `_PyStackRef`. ```c // A stackref that can be stored in a regular C local variable and be visible // to the GC in the free threading build. // Used in combination with _PyThreadState_PushCStackRef(). typedef struct _PyCStackRef { _PyStackRef ref; #ifdef Py_GIL_DISABLED struct _PyCStackRef *next; #endif } _PyCStackRef; struct _PyThreadStateImpl { ... // Linked list (stack) of active _PyCStackRef struct _PyCStackRef *c_stack_refs; ... } static inline void _PyThreadState_PushCStackRef(PyThreadState *tstate, _PyCStackRef *ref) { ... } static inline void _PyThreadState_PopCStackRef(PyThreadState *tstate, _PyCStackRef *ref) { ... } ``` cc @mpage @markshannon <!-- gh-linked-prs --> ### Linked PRs * gh-131588 * gh-131851 <!-- /gh-linked-prs -->
67fbfb42bd5dfe861d0c58d9e6c48d8eef033d24
3d4ac1a2c2b610f35a9e164878d67185e4a3546f
python/cpython
python__cpython-131567
# `tracemalloc.start()` and `tracemalloc.stop()` race condition This occurs in both the GIL-enabled build and the free threaded build. It only happens in release builds, because `test_tracemalloc.test_tracemalloc_track_race` is skipped in debug builds. Tracemalloc modifies the global "raw" memory allocator. The modification happens under a lock, but other calls to `PyMem_RawMalloc` and `PyMem_RawFree` can occur without any locking and without holding the GIL. I think the "fix" is to just skip the test when running under TSAN: * I don't think there's any better fix -- we definitely don't want `PyMem_RawMalloc()` to require locks * The race is relatively "benign" -- I don't think it'll cause any crashes in practice * Tracemalloc is primarily a debugging tool Here's an example stack trace: ``` WARNING: ThreadSanitizer: data race (pid=3203004) Write of size 8 at 0x555555cee008 by main thread: #0 __tsan_memcpy <null> (python+0xdff2e) (BuildId: 3f2abce6d83666bdd9fffb9ab44aef8621970a54) #1 set_allocator_unlocked /raid/sgross/cpython/Objects/obmalloc.c (python+0x29d9aa) (BuildId: 3f2abce6d83666bdd9fffb9ab44aef8621970a54) #2 PyMem_SetAllocator /raid/sgross/cpython/Objects/obmalloc.c:899:5 (python+0x29d9aa) #3 _PyTraceMalloc_Start /raid/sgross/cpython/Python/tracemalloc.c:825:5 (python+0x49bdb4) (BuildId: 3f2abce6d83666bdd9fffb9ab44aef8621970a54) #4 _tracemalloc_start_impl /raid/sgross/cpython/./Modules/_tracemalloc.c:99:9 (python+0x4d5db8) (BuildId: 3f2abce6d83666bdd9fffb9ab44aef8621970a54) #5 _tracemalloc_start /raid/sgross/cpython/./Modules/clinic/_tracemalloc.c.h:111:20 (python+0x4d5db8) ... Previous read of size 8 at 0x555555cee008 by thread T1: #0 PyMem_RawFree /raid/sgross/cpython/Objects/obmalloc.c:989:32 (python+0x29dda7) (BuildId: 3f2abce6d83666bdd9fffb9ab44aef8621970a54) #1 pythread_wrapper /raid/sgross/cpython/Python/thread_pthread.h:240:5 (python+0x498861) (BuildId: 3f2abce6d83666bdd9fffb9ab44aef8621970a54) ``` https://github.com/python/cpython/blob/b92ee14b80cc8898f799aa8120ec99dd0c882339/Python/tracemalloc.c#L825 https://github.com/python/cpython/blob/b92ee14b80cc8898f799aa8120ec99dd0c882339/Python/thread_pthread.h#L233-L244 See also: * https://github.com/python/cpython/issues/128679 * https://github.com/python/cpython/issues/111924 <!-- gh-linked-prs --> ### Linked PRs * gh-131567 <!-- /gh-linked-prs -->
18249d938335312d618a3962ec7590bea709d58e
996246994341c91308364f3ed018cf9b7fec9bc8
python/cpython
python__cpython-132015
# `PyType_AddWatcher` and friends are not thread safe in free-threading `PyType_AddWatcher` and `PyType_ClearWatcher` are not thread safe as it modifies the interp's type watchers non-atomically. `PyType_AddWatcher`: https://github.com/python/cpython/blob/d3f6063af18a008e316e4342492e877ee51463e2/Objects/typeobject.c#L949-L963 `PyType_ClearWatcher`: https://github.com/python/cpython/blob/d3f6063af18a008e316e4342492e877ee51463e2/Objects/typeobject.c#L980-L989 I think adding and removing of type watchers is a rare event so maybe instead of adding atomics or locks it would be better to change them to use stop-the-world pause event. <!-- gh-linked-prs --> ### Linked PRs * gh-132015 * gh-132019 <!-- /gh-linked-prs -->
25275bda790e8a689092e83855d6d0574f26061b
e8085319eb20aca7c0f8507aece505461db4f578
python/cpython
python__cpython-131551
# html.parser produces different output than documented When parsing &gt;&#62;&#x3E; using html.parser, the actual output differs from the expected behavior as documented. Run the following code: ```python from html.parser import HTMLParser from html.entities import name2codepoint class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print("Start tag:", tag) for attr in attrs: print(" attr:", attr) def handle_endtag(self, tag): print("End tag :", tag) def handle_data(self, data): print("Data :", data) def handle_comment(self, data): print("Comment :", data) def handle_entityref(self, name): c = chr(name2codepoint[name]) print("Named ent:", c) def handle_charref(self, name): if name.startswith('x'): c = chr(int(name[1:], 16)) else: c = chr(int(name)) print("Num ent :", c) def handle_decl(self, data): print("Decl :", data) parser = MyHTMLParser() parser.feed('&gt;&#62;&#x3E;') ``` According to the documentation, the expected output should be: ``` Named ent: > Num ent : > Num ent : > ``` The actual output is: ``` Data : >>> ``` <!-- gh-linked-prs --> ### Linked PRs * gh-131551 * gh-133587 * gh-133589 <!-- /gh-linked-prs -->
ee76e36d76a0e6916c0afc41228b043ab5174685
77b14a6d58e527f915966446eb0866652a46feb5
python/cpython
python__cpython-131532
# Android cibuildwheel support # Feature or enhancement ### Proposal: This issue will link together a number of PRs required to support running cibuildwheel for Android. Specifically, we need the following features: * Produce a release package containing a pre-compiled Python for Android. * Enable the testbed app to run arbitrary tests on third-party packages. ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere <!-- gh-linked-prs --> ### Linked PRs * gh-131532 * gh-131960 * gh-132870 * gh-133193 * gh-133236 * gh-135158 * gh-135164 * gh-136845 * gh-136962 * gh-136963 <!-- /gh-linked-prs -->
fe5c4c53e7bc6d780686013eaab17de2237b2176
45a3ab5a81769eadd94da3e26eb9bb2f3ae80fb1