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-131529
# Caching the tuple hash calculation speeds up some code significantly ### Proposal: [Back in 2013](https://bugs.python.org/issue9685), it was determined that caching the result of `tuple_hash` did not have any significant speedup. However, a lot has changed since then, and in a [recent experiment](https://github.com/faster-cpython/benchmarking/blob/main/results/bm-20250320-3.14.0a6%2B-a31e8be/bm-20250320-pythonperf2-x86_64-mdboom-tuple_hash_cache2-3.14.0a6%2B-a31e8be-vs-base.svg) to add a tuple hash cache back in, the [mdp benchmark](https://github.com/python/pyperformance/blob/main/pyperformance/data-files/benchmarks/bm_mdp/run_benchmark.py) increased by 86%. Admittedly, there was no measurable improvement on any other benchmark, but it also seems to have no downside, including for [memory usage](https://github.com/faster-cpython/benchmarking/blob/main/results/bm-20250320-3.14.0a6%2B-a31e8be/bm-20250320-pythonperf2-x86_64-mdboom-tuple_hash_cache2-3.14.0a6%2B-a31e8be-vs-base-mem.svg) when measured with `max_rss`. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: - [ ] <!-- gh-linked-prs --> ### Linked PRs * gh-131529 * gh-131922 <!-- /gh-linked-prs -->
8614f86b7163b1c39798b481902dbb511292a537
cf5e438c0297954c4411c1c3ae4ba67a48b134ea
python/cpython
python__cpython-131542
# Improve `platform` CLI # Feature or enhancement ### Proposal: Currently, the `platform` module's CLI is fairly hidden and inaccessible. I think there are two main issues with the module CLI. 1. There is no "Command Line Interface" section of the [docs](https://docs.python.org/3/library/platform.html#module-platform) like there is with some other modules e.g. [random](https://docs.python.org/3/library/random.html#command-line-usage). (It is, however, listed under the [Modules command-line interface](https://docs.python.org/3/library/cmdline.html) section) 2. There is no help section when running the platform CLI, the CLI takes two arguments `--terse` and `--nonaliased`, which I could only find from looking at the source in [Lib/platform.py](https://github.com/python/cpython/blob/646b453a15eecf66c02793751718a937147d0c15/Lib/platform.py). ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131542 <!-- /gh-linked-prs -->
77c391a1b178a35b0157e00689acb3904b77694d
ac56f8cc8d36ed65228d7eaa245569f66ad16d2b
python/cpython
python__cpython-131526
# clang-cl on Windows fails to compile after zlib-ng Since https://github.com/python/cpython/pull/131438, clang-cl fails to compile, see e.g. the tailcall Windows CI https://github.com/python/cpython/actions/runs/13967899073/job/39102464260 Discussion started with @zooba in https://github.com/python/cpython/pull/131438#issuecomment-2741211464. <!-- gh-linked-prs --> ### Linked PRs * gh-131526 <!-- /gh-linked-prs -->
d16f455cd8cabbc1e7bd2369cdb8718c30ab8957
1d6a2e648130cd834f7ed4fd210ef7dd4d4fc797
python/cpython
python__cpython-131515
# Code generator is overly restrictive about writing to input variables. # Bug report ### Bug description: In https://github.com/python/cpython/pull/130708/files#r2005817604 we want to replace an input variable, writing `v = PyStackRef_MakeHeapSafe(v);` but the code generator rejects this as unsafe: "writing to an input variable". This mostly a good restriction as we don't want to accidentally lose a reference, but we should allow the replacement when it is safe. This should be allowed: ``` tmp = PyStackRef_MakeHeapSafe(v); DEAD(v); v = tmp; ``` As we only write to a dead variable, which is safe. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131515 <!-- /gh-linked-prs -->
d3f6063af18a008e316e4342492e877ee51463e2
b70d45ab22e1d0f3b8a0b6ff5ff71157da5f2dfb
python/cpython
python__cpython-131509
# Syntax highlighting in PyREPL We want PyREPL to syntax highlight Python code, like this: <img width="796" alt="Image" src="https://github.com/user-attachments/assets/5bb47d56-2e80-4a9f-92c8-173f2836f4fb" /> Theming support is planned, but a separate concern. This issue is about enabling syntax to highlight correctly whenever color is used within the REPL anyway. This is a feature for 3.14, with some test and code refactors that we will be bringing back to 3.13 for improved future maintenance. <!-- gh-linked-prs --> ### Linked PRs * gh-131509 * gh-131546 * gh-131547 * gh-131557 * gh-131562 * gh-132270 * gh-132274 * gh-132293 * gh-133247 <!-- /gh-linked-prs -->
4cc82ffa377db5073fdc6f85c6f35f9c47397796
61317074d450f72fa121ceb1c7b0c52698a71106
python/cpython
python__cpython-131536
# Checking len bounds after usage in bytesio.c In _io_BytesIO_readinto_impl() len value is used in memcpy and then checked for being positive. It's better to move assertions before memcpy. This may be done with the following commit: https://github.com/python/cpython/commit/da720c10f6d841737195ca49440a038ae29bc9b9 <!-- gh-linked-prs --> ### Linked PRs * gh-131536 * gh-134239 <!-- /gh-linked-prs -->
c45e661226558e997e265cf53ce1419213cc10b7
3fa30d9e9c13c4b84bdc9fc04e33130775679e98
python/cpython
python__cpython-131499
# Top-of-stack caching in the interpreter [Top-of-stack caching](https://dl.acm.org/doi/pdf/10.1145/223428.207165) is technique where one or more values on the top of the stack are kept in local variables, with the assumption that the C compiler will put them in registers. We should implement this for the interpreter (tier 1). We cannot afford to increase the number of instructions by much, so we'll have to use a fixed size cache of 1. This will likely only produce a modest speedup, as the total memory traffic is unlikely to decrease. There should be some ILP improvements. The main benefit of TOS caching is likely to be in the JIT where we can use a variable sized cache. We want to do it in the interpreter first though, as it will be simpler and requires a subset of the changes needed for the JIT. <!-- gh-linked-prs --> ### Linked PRs * gh-131499 * gh-131827 * gh-131948 * gh-132074 * gh-132506 * gh-132615 <!-- /gh-linked-prs -->
7ebd71ee14a497bb5dc7a693dd00f074a9f4831f
443c0cd17c5b0c71ee45c3621777454c6b8b0cbd
python/cpython
python__cpython-131462
# GzipFile leaves GzipFile.myfileobject open in constructor if exception is raised # Bug report ### Bug description: consider the following program, it should raise an ExceptionGroup(..., [ValueError(), ValueError(), ...] but actually it raises OSError: [Errno 24] Too many open files: '/tmp/tmpk8gaprry' ```python import gzip import tempfile import pathlib import os def main(): with tempfile.TemporaryDirectory() as tmp_dir: tmp_path = pathlib.Path(tmp_dir) zip_path = tmp_path / "some_file.zip" exceptions = [] for i in range(2000): try: gzip.GzipFile(filename=os.fsdecode(zip_path), mode="w", compresslevel=99) except ValueError as e: exceptions.append(e) if exceptions: raise ExceptionGroup("multiple errors creating GzipFiles", exceptions) main() ``` ### CPython versions tested on: CPython main branch, 3.14, 3.13, 3.12, 3.11 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131462 * gh-131518 * gh-131519 <!-- /gh-linked-prs -->
ce79274e9f093bd06d2285c9af48dbcbc92173de
f53e7de6a84a0f535efb75c3671283b801a1af0f
python/cpython
python__cpython-131475
# clang-cl on Windows still needs PreferredToolArchitecture I hoped I fixed it in https://github.com/python/cpython/pull/129907/commits/263870dd319e79170f42fc5e05beb3879effff7b, but it turned out, that this is not enough, see https://github.com/astral-sh/python-build-standalone/pull/549#issuecomment-2734831192. Digging in deeper, I now know more, but do not have an ideal fix, yet. First, for `Hacl_Hash_Blake2b_Simd256.c` ``` <AdditionalOptions>/arch:AVX2</AdditionalOptions> ``` is missing `%(AdditionalOptions)`. Likewise, `Hacl_Hash_Blake2s_Simd128.c`. Then, both will "see" the `-m32`/ `-m64` defined in https://github.com/python/cpython/blob/0a54bd6dd7cda3b9611bf33652184c477a332c7e/PCbuild/pyproject-clangcl.props#L42-L43 This will fix regular release or debug builds (https://github.com/python/cpython/pull/131475), since they do not have to link against anything from clang. But unfortunately, for PGO builds, clang-cl needs to link against `clang_rt.profile.lib`: - `<VS install path>\Community\VC\Tools\Llvm\lib\clang\<clang major version>\lib\windows\clang_rt.profile-i386.lib` - `<VS install path>\Community\VC\Tools\Llvm\x64\lib\clang\<clang major version>\lib\windows\clang_rt.profile-x86_64.lib` This is not found correctly without setting `PreferredToolArchitecture` (or `LLVMInstallDir`). The reason stems from `<VS install path>\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.ClangCl.Common.props`: ``` <_DefaultLLVMInstallDir Condition="'$(_DefaultLLVMInstallDir)' == '' AND '$(PreferredToolArchitecture)' == 'arm64'">$(VsInstallRoot)\VC\Tools\Llvm\ARM64</_DefaultLLVMInstallDir> <_DefaultLLVMInstallDir Condition="'$(_DefaultLLVMInstallDir)' == '' AND '$(PreferredToolArchitecture)' == 'x64'">$(VsInstallRoot)\VC\Tools\Llvm\x64</_DefaultLLVMInstallDir> <_DefaultLLVMInstallDir Condition="'$(_DefaultLLVMInstallDir)' == '' AND '$(PreferredToolArchitecture)' != 'x64'">$(VsInstallRoot)\VC\Tools\Llvm</_DefaultLLVMInstallDir> <LLVMInstallDir Condition="'$(LLVMInstallDir)' == ''">$(_DefaultLLVMInstallDir)</LLVMInstallDir> ``` This means, if `PreferredToolArchitecture` is not given on the command line, for a 64bit build the `LLVMInstallDir` is chosen to be the "32bit clang installation". Even though this one will happily "cross-compile" getting the `-m64` switch, it will fail in the link step, because the 64bit libs are "in the 64bit clang installation directory". See also https://learn.microsoft.com/en-us/cpp/build/reference/msbuild-visual-cpp-overview?view=msvc-170#preferredtoolarchitecture-property: > The PreferredToolArchitecture property determines whether the 32-bit or 64-bit compiler and tools are used in the build. I am unsure what to do here: - try to fix that somewhere in `pyproject-clangcl.props`: not so easy, because "too late": `LLVMInstallDir` will always be set here, either because - given on the command line, i.e. custom clang installation - or `Microsoft.Cpp.ClangCl.Common.props` will already have set it to the bundled clang installation based on `PreferredToolArchitecture` - ask Microsoft to fix that? There are some hits about this behaviour in the net ... - document (again, but this time I have more background knowledge) that the user is responsible to either - set `PreferredToolArchitecture` correctly when using the bundled version - set `LLVMInstallDir` to a 32bit installation for 32bit builds and similarily for 64bit builds. See [here](https://github.com/python/cpython/pull/129907#issuecomment-2646406083), why I personally anyways always set `PreferredToolArchitecture` (spoiler: I do not like the `_freeze_module` to be compiled as 32bit, for exactly the same reason: if `PreferredToolArchitecture` is missing, it defaults to 32bit). Most probably an unwanted side effect of https://github.com/python/cpython/pull/28491/files or the lesser evil :) ISTM, I returned to this habit too quickly, and so I missed that rabit hole - but now I've dug deeper. FTR, this will also be needed when someone wants to do ASAN, UBSAN, FUZZER, etc, builds using clang-cl on Windows, because in all those cases the correct libs are needed. <!-- gh-linked-prs --> ### Linked PRs * gh-131475 * gh-131689 <!-- /gh-linked-prs -->
54efe296bc3f3e421b57d4487bb87ad4161600b2
8abfaba5a67a99c446f0c13253ee0ce97bf6fa5c
python/cpython
python__cpython-131462
# ResourceWarning in GzipFile (write mode) if constructor raises (3.14 only) # Bug report ### Bug description: ```python import io import gzip class BadFile(io.BytesIO): first = False def write(self, data): if self.first: self.first = False raise OSError def main(): try: gzip.GzipFile(fileobj=BadFile(), mode="w") except OSError: pass main() ``` when run produces: ``` ./python -W error ../../demo.py Exception ignored while calling deallocator <function GzipFile.__del__ at 0x7b14defe09e0>: Traceback (most recent call last): File "/home/graingert/projects/cpython/Lib/gzip.py", line 458, in __del__ warnings.warn("unclosed GzipFile", ResourceWarning: unclosed GzipFile ``` This warning is also raised by the test suite, in test_tarfile.WriteTestBase.test_open_nonwritable_fileobj ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131462 <!-- /gh-linked-prs -->
ce79274e9f093bd06d2285c9af48dbcbc92173de
f53e7de6a84a0f535efb75c3671283b801a1af0f
python/cpython
python__cpython-131460
# Typo in BNF description of function signatures # Documentation The definition of `parameter_list_starargs` is missing a `|`: ``` parameter_list_starargs ::= "*" [star_parameter] ("," defparameter)* ["," [parameter_star_kwargs]] "*" ("," defparameter)+ ["," [parameter_star_kwargs]] | parameter_star_kwargs ``` should be ``` parameter_list_starargs ::= "*" [star_parameter] ("," defparameter)* ["," [parameter_star_kwargs]] | "*" ("," defparameter)+ ["," [parameter_star_kwargs]] | parameter_star_kwargs ``` Without that `|`, the definition says that you can have two `*` symbols in a signature. With the `|`, the second line describes "keyword only" arguments. Link to current docs: https://docs.python.org/3/reference/compound_stmts.html#function-definitions <!-- gh-linked-prs --> ### Linked PRs * gh-131460 * gh-131575 * gh-131576 <!-- /gh-linked-prs -->
8b7d20d3a9dc53344e3803507deafc26b5c09ca8
49fb75c676bd422b03aef9824d1abca1e9d90193
python/cpython
python__cpython-131454
# Some macros are missing in `winsound` module. # Feature or enhancement ### Proposal: Currently we have `SND_*` macros for `winsound.PlaySound` and `MB_*` macros for `winsound.MessageBeep`, but some macros are missing from Microsoft's document: https://learn.microsoft.com/en-us/previous-versions/dd743680(v=vs.85) https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebeep A PR is on the way. ### 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-131454 <!-- /gh-linked-prs -->
00a984488894a4e6674018f449eb9ec0cee3a9a1
a2ea4175786e684dd0c1751d49f869e2e4a80e30
python/cpython
python__cpython-131442
# Add a set of asserts to test.test_capi.test_list Add a set of asserts to enhance `test.test_capi.test_list` test. For example, this test lacks some of the **0-sized** tests for some cases, and there is room for other **asserts**. <!-- gh-linked-prs --> ### Linked PRs * gh-131442 * gh-131523 * gh-131533 <!-- /gh-linked-prs -->
2433cc79d79d9c1db8e53d4b9bde26e9a47fb0b9
39b37b0110d0faaa25d7cdaab008f856eec8173c
python/cpython
python__cpython-131436
# random.randint performance improvement # Feature or enhancement ### Proposal: `randint` is a commonly needed function, but it is fairly slow (compared to `random.random`). Maybe it would be good to port couple of lower level functions to `C`. But for the time being, this small edit results in 20% better performance by avoiding unnecessary abstractions. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131436 <!-- /gh-linked-prs -->
c83efa7a66e30276c328fa4a5f8f8d26977f3e1c
ce79274e9f093bd06d2285c9af48dbcbc92173de
python/cpython
python__cpython-131568
# `datetime.strptime` no longer raises `ValueError: stray % in format '%Y %'` # Bug report ### Bug description: in 3.13.2 and 3.13.1 `datetime.strptime` no longer raises `ValueError: stray % in format '%Y %'` ``` Python 3.13.2 (main, Mar 19 2025, 01:28:14) [Clang 16.0.0 (clang-1600.0.26.6)] on Darwin >>> from datetime import datetime >>> datetime.strptime("2000 %", "%Y %") datetime.datetime(2000, 1, 1, 0, 0) ``` as it used to do in 3.13.0: ``` Python 3.13.0 (main, Mar 19 2025, 01:42:48) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin >>> from datetime import datetime >>> datetime.strptime("2000 %", "%Y %") Traceback (most recent call last): File "<python-input-1>", line 1, in <module> datetime.strptime("2000 %", "%Y %") ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ File "/Users/nik/.pyenv/versions/3.13.0/lib/python3.13/_strptime.py", line 573, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "/Users/nik/.pyenv/versions/3.13.0/lib/python3.13/_strptime.py", line 348, in _strptime raise ValueError("stray %% in format '%s'" % format) from None ValueError: stray % in format '%Y %' ``` and e.g. 3.10: ``` Python 3.10.15 (main, Nov 28 2024, 23:39:17) [Clang 16.0.0 (clang-1600.0.26.4)] on Darwin >>> from datetime import datetime >>> datetime.strptime("2000 %", "%Y %") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/nik/.pyenv/versions/3.10.15/lib/python3.10/_strptime.py", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) File "/Users/nik/.pyenv/versions/3.10.15/lib/python3.10/_strptime.py", line 345, in _strptime raise ValueError("stray %% in format '%s'" % format) from None ValueError: stray % in format '%Y %' ``` edit 1: got the same in the latest 3.12.9 (used to work in older 3.12) ### CPython versions tested on: 3.13 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-131568 * gh-132309 <!-- /gh-linked-prs -->
3feac7a093b3fcd549c5dc54277f26f585f2ab0c
7ebbd271444d89218870169624921b795a717470
python/cpython
python__cpython-131839
# Update OpenSSL versions for CI and Windows OpenSSL v3.4.1 is out and contains some security patches (see https://github.com/openssl/openssl/releases/tag/openssl-3.4.1). There is one high vulnerabilty ([CVE-2024-12797](https://nvd.nist.gov/vuln/detail/CVE-2024-12797)) that was fixed. However, what I'm interested in, are the fixes that allow me to continue working on #128391 (see https://github.com/openssl/openssl/issues/26388). Note that this high vulnerability does not affect the Windows build as the latter is still using OpenSSL 3.0.15 which is only affected by the following low vulnerabilities: - [CVE-2024-13176](https://openssl-library.org/news/vulnerabilities/#CVE-2024-13176) - [CVE-2024-9143](https://openssl-library.org/news/vulnerabilities/#CVE-2024-9143) Those low vulnerabilities affect OpenSSL 1.1.1+ and 3.x versions that we currently use and were fixed in the February 2025 release. Note: I don't think Python is directly affected by the low vulnerabilies and I just want the fixes that were included in those releases for my own work. Since the high vulnerability only affects 3.2+, Windows builds should not be affected. cc @gpshead ### Plan: - [x] Update https://github.com/python/cpython-source-deps to pull OpenSSL 3.0.16 (cc @zooba) - [x] Update macOS and Windows builds to use OpenSSL 3.0.16. - [x] Update CI workflows to test against [3.0.16, 3.1.8, 3.2.4, 3.3.3, 3.4.1] - [x] Update OpenSSL data headers <!-- gh-linked-prs --> ### Linked PRs * gh-131839 * gh-131848 * gh-131849 * gh-132051 * gh-132052 * gh-132053 * gh-132189 * gh-132196 * gh-132197 * gh-131618 * gh-133077 <!-- /gh-linked-prs -->
d260631be063d97f1a6d1c8f9fa2ce9b0e4f8a58
ce77da5871334bffea722984cb705fd20a763a1f
python/cpython
python__cpython-131419
# Wrong `Python.asdl` type for `keys` in `Dict` literals In the `Python.asdl` syntax description, the file asserts that `Dict` literal `keys` have type `expr*`. This is false. `keys` can be optional. In the ast documentation for Python: * https://docs.python.org/3/library/ast.html#ast.Dict it is made clear that: > When doing dictionary unpacking using dictionary literals the expression to be expanded goes in the values list, with a None at the corresponding position in keys. Hence, keys is really a expr?* and not a expr*. <!-- gh-linked-prs --> ### Linked PRs * gh-131419 * gh-133408 * gh-133773 <!-- /gh-linked-prs -->
483d130e504f63aaf3afe8af3a37650edcdb07a3
30840706b029645b9631b92c687834fcced6413e
python/cpython
python__cpython-131420
# Remove un-necessary typedefs in `md5module.c` and `sha1module.c` We have some legacy typedefs that are no more needed as we're using HACL* and not our own implementation for MD5 and SHA-1: ```c #if SIZEOF_INT == 4 typedef unsigned int MD5_INT32; /* 32-bit integer */ typedef long long MD5_INT64; /* 64-bit integer */ #else /* not defined. compilation will die. */ #endif ``` ```c #if SIZEOF_INT == 4 typedef unsigned int SHA1_INT32; /* 32-bit integer */ typedef long long SHA1_INT64; /* 64-bit integer */ #else /* not defined. compilation will die. */ #endif ``` <!-- gh-linked-prs --> ### Linked PRs * gh-131420 * gh-131619 * gh-131620 <!-- /gh-linked-prs -->
a9a399f0ecfeeff91425cc089057f1b95799853b
f3bf304c2799c31c045033f22db7eb8766a5f939
python/cpython
python__cpython-131422
# stdtypes don't mention asyncio generic classes # Documentation https://docs.python.org/3/library/stdtypes.html#standard-generic-classes has a list of generic classes. Since ea5b96842e066623a53015d8b2492ed61a5baf96, `asyncio` provides generic Future and Task that are not mentioned. <!-- gh-linked-prs --> ### Linked PRs * gh-131422 * gh-131445 * gh-131446 <!-- /gh-linked-prs -->
61b4b2c57c9327273f2e306bafa23cf2c70eac8e
267c06d6a8290aa299098b4fcd3f270001b01e72
python/cpython
python__cpython-131407
# Extend HMAC tests by using NIST test vectors # Feature or enhancement Currently we do not test HMAC-SHA3 implementation. There is no RFC for test cases, but the NIST gives test vectors: https://csrc.nist.gov/Projects/cryptographic-standards-and-guidelines/example-values. I also need to find a way to declare test vectors more easily, and for that I think a separat module is probably easier but I'll first add SHA3 tests and NIST test vectors. <!-- gh-linked-prs --> ### Linked PRs * gh-131407 <!-- /gh-linked-prs -->
8cb57dc3678a8b26772d0fffce525762fee4f234
83479c217523c277cccb9db1e214d99b1c9d6343
python/cpython
python__cpython-131406
# TSAN data race in _PyErr_Restore When running asyncio tests with forever mode, the following race is detected: ```console 0:04:28 load avg: 13.03 [121/1] test_asyncio.test_tasks worker non-zero exit code (Exit code 66) -- running (3): test_asyncio.test_events (1 min 4 sec), test_asyncio.test_sendfile (32.5 sec), test_asyncio.test_tasks (1 min 28 sec) ================== WARNING: ThreadSanitizer: data race (pid=4663) Read of size 8 at 0x7f754ba233f8 by main thread: #0 PyException_GetTraceback Objects/exceptions.c:524 (python+0x1800f4) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #1 PyTraceBack_Here Python/traceback.c:276 (python+0x473168) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #2 _PyEval_EvalFrameDefault Python/generated_cases.c.h:12134 (python+0x87bcf) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #3 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #4 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #5 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #6 _PyObject_VectorcallTstate Include/internal/pycore_call.h:168 (python+0x15567d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #7 method_vectorcall Objects/classobject.c:94 (python+0x15567d) #8 _PyVectorcall_Call Objects/call.c:273 (python+0x152137) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #9 _PyObject_Call Objects/call.c:348 (python+0x1526f1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #10 PyObject_Call Objects/call.c:373 (python+0x1526f1) #11 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #12 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #13 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #14 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #15 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151d9e) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #16 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520b3) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #17 slot_tp_call Objects/typeobject.c:10061 (python+0x27af43) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #18 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14ea92) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #19 _PyObject_VectorcallTstate Include/internal/pycore_call.h:166 (python+0x14fa18) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #20 _PyObject_VectorcallTstate Include/internal/pycore_call.h:153 (python+0x14fa18) #21 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa18) #22 _PyEval_EvalFrameDefault Python/generated_cases.c.h:3837 (python+0x8bba6) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #23 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #24 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #25 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #26 _PyObject_VectorcallTstate Include/internal/pycore_call.h:168 (python+0x15567d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #27 method_vectorcall Objects/classobject.c:94 (python+0x15567d) #28 _PyVectorcall_Call Objects/call.c:273 (python+0x152137) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #29 _PyObject_Call Objects/call.c:348 (python+0x1526f1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #30 PyObject_Call Objects/call.c:373 (python+0x1526f1) #31 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #32 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #33 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #34 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #35 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151d9e) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #36 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520b3) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #37 slot_tp_call Objects/typeobject.c:10061 (python+0x27af43) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #38 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14ea92) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #39 _PyObject_VectorcallTstate Include/internal/pycore_call.h:166 (python+0x14fa18) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #40 _PyObject_VectorcallTstate Include/internal/pycore_call.h:153 (python+0x14fa18) #41 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa18) #42 _PyEval_EvalFrameDefault Python/generated_cases.c.h:3837 (python+0x8bba6) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #43 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #44 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #45 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #46 _PyObject_VectorcallTstate Include/internal/pycore_call.h:168 (python+0x15567d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #47 method_vectorcall Objects/classobject.c:94 (python+0x15567d) #48 _PyVectorcall_Call Objects/call.c:273 (python+0x152137) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #49 _PyObject_Call Objects/call.c:348 (python+0x1526f1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #50 PyObject_Call Objects/call.c:373 (python+0x1526f1) #51 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #52 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #53 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #54 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #55 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151d9e) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #56 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520b3) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #57 slot_tp_call Objects/typeobject.c:10061 (python+0x27af43) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #58 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14ea92) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #59 _PyObject_VectorcallTstate Include/internal/pycore_call.h:166 (python+0x14fa18) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #60 _PyObject_VectorcallTstate Include/internal/pycore_call.h:153 (python+0x14fa18) #61 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa18) #62 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1375 (python+0x8bfa8) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #63 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381d04) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #64 _PyEval_Vector Python/ceval.c:1903 (python+0x381d04) #65 PyEval_EvalCode Python/ceval.c:831 (python+0x381d04) #66 builtin_exec_impl Python/bltinmodule.c:1156 (python+0x36f006) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #67 builtin_exec Python/clinic/bltinmodule.c.h:560 (python+0x36f006) #68 cfunction_vectorcall_FASTCALL_KEYWORDS Objects/methodobject.c:452 (python+0x203bd9) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #69 _PyObject_VectorcallTstate Include/internal/pycore_call.h:168 (python+0x14f921) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #70 PyObject_Vectorcall Objects/call.c:327 (python+0x14f921) #71 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1375 (python+0x8bfa8) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #72 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #73 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #74 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #75 _PyVectorcall_Call Objects/call.c:273 (python+0x152137) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #76 _PyObject_Call Objects/call.c:348 (python+0x1526f1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #77 PyObject_Call Objects/call.c:373 (python+0x1526f1) #78 pymain_run_module Modules/main.c:337 (python+0x48ee2c) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #79 pymain_run_python Modules/main.c:673 (python+0x48fb8c) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #80 Py_RunMain Modules/main.c:760 (python+0x491042) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #81 pymain_main Modules/main.c:790 (python+0x491042) #82 Py_BytesMain Modules/main.c:814 (python+0x491042) #83 main Programs/python.c:15 (python+0x85ce2) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) Previous write of size 8 at 0x7f754ba233f8 by thread T6: #0 _PyErr_Restore Python/errors.c:103 (python+0x3c0b47) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #1 _PyErr_SetObject Python/errors.c:248 (python+0x3be492) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #2 do_raise Python/ceval.c:2069 (python+0x377a04) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #3 _PyEval_EvalFrameDefault Python/generated_cases.c.h:10137 (python+0x99acb) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #4 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #5 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #6 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #7 _PyObject_VectorcallTstate Include/internal/pycore_call.h:168 (python+0x1557f8) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #8 method_vectorcall Objects/classobject.c:72 (python+0x1557f8) #9 _PyVectorcall_Call Objects/call.c:273 (python+0x152137) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #10 _PyObject_Call Objects/call.c:348 (python+0x1526f1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #11 PyObject_Call Objects/call.c:373 (python+0x1526f1) #12 thread_run Modules/_threadmodule.c:352 (python+0x537935) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #13 pythread_wrapper Python/thread_pthread.h:242 (python+0x46f499) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) Thread T6 'asyncio_0' (tid=7712, running) created by main thread at: #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so.2+0x5ac1a) (BuildId: 38097064631f7912bd33117a9c83d08b42e15571) #1 do_start_joinable_thread Python/thread_pthread.h:289 (python+0x46f92e) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #2 PyThread_start_joinable_thread Python/thread_pthread.h:313 (python+0x46f92e) #3 ThreadHandle_start Modules/_threadmodule.c:437 (python+0x538cb8) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #4 do_start_new_thread Modules/_threadmodule.c:1822 (python+0x538cb8) #5 thread_PyThread_start_joinable_thread Modules/_threadmodule.c:1945 (python+0x5395d1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #6 cfunction_call Objects/methodobject.c:551 (python+0x203dd6) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #7 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14ea92) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #8 _PyObject_VectorcallTstate Include/internal/pycore_call.h:166 (python+0x14fa18) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #9 _PyObject_VectorcallTstate Include/internal/pycore_call.h:153 (python+0x14fa18) #10 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa18) #11 _PyEval_EvalFrameDefault Python/generated_cases.c.h:3012 (python+0x8d3aa) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #12 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #13 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #14 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #15 _PyObject_VectorcallTstate Include/internal/pycore_call.h:168 (python+0x15567d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #16 method_vectorcall Objects/classobject.c:94 (python+0x15567d) #17 _PyVectorcall_Call Objects/call.c:273 (python+0x152137) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #18 _PyObject_Call Objects/call.c:348 (python+0x1526f1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #19 PyObject_Call Objects/call.c:373 (python+0x1526f1) #20 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #21 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #22 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #23 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #24 _PyObject_VectorcallTstate Include/internal/pycore_call.h:168 (python+0x15567d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #25 method_vectorcall Objects/classobject.c:94 (python+0x15567d) #26 _PyVectorcall_Call Objects/call.c:273 (python+0x152137) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #27 _PyObject_Call Objects/call.c:348 (python+0x1526f1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #28 PyObject_Call Objects/call.c:373 (python+0x1526f1) #29 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #30 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #31 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #32 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #33 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151d9e) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #34 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520b3) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #35 slot_tp_call Objects/typeobject.c:10061 (python+0x27af43) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #36 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14ea92) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #37 _PyObject_VectorcallTstate Include/internal/pycore_call.h:166 (python+0x14fa18) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #38 _PyObject_VectorcallTstate Include/internal/pycore_call.h:153 (python+0x14fa18) #39 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa18) #40 _PyEval_EvalFrameDefault Python/generated_cases.c.h:3837 (python+0x8bba6) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #41 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #42 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #43 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #44 _PyObject_VectorcallTstate Include/internal/pycore_call.h:168 (python+0x15567d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #45 method_vectorcall Objects/classobject.c:94 (python+0x15567d) #46 _PyVectorcall_Call Objects/call.c:273 (python+0x152137) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #47 _PyObject_Call Objects/call.c:348 (python+0x1526f1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #48 PyObject_Call Objects/call.c:373 (python+0x1526f1) #49 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #50 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #51 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #52 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #53 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151d9e) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #54 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520b3) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #55 slot_tp_call Objects/typeobject.c:10061 (python+0x27af43) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #56 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14ea92) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #57 _PyObject_VectorcallTstate Include/internal/pycore_call.h:166 (python+0x14fa18) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #58 _PyObject_VectorcallTstate Include/internal/pycore_call.h:153 (python+0x14fa18) #59 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa18) #60 _PyEval_EvalFrameDefault Python/generated_cases.c.h:3837 (python+0x8bba6) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #61 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #62 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #63 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #64 _PyObject_VectorcallTstate Include/internal/pycore_call.h:168 (python+0x15567d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #65 method_vectorcall Objects/classobject.c:94 (python+0x15567d) #66 _PyVectorcall_Call Objects/call.c:273 (python+0x152137) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #67 _PyObject_Call Objects/call.c:348 (python+0x1526f1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #68 PyObject_Call Objects/call.c:373 (python+0x1526f1) #69 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #70 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #71 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #72 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #73 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151d9e) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #74 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520b3) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #75 slot_tp_call Objects/typeobject.c:10061 (python+0x27af43) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #76 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14ea92) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #77 _PyObject_VectorcallTstate Include/internal/pycore_call.h:166 (python+0x14fa18) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #78 _PyObject_VectorcallTstate Include/internal/pycore_call.h:153 (python+0x14fa18) #79 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa18) #80 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1375 (python+0x8bfa8) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #81 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381d04) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #82 _PyEval_Vector Python/ceval.c:1903 (python+0x381d04) #83 PyEval_EvalCode Python/ceval.c:831 (python+0x381d04) #84 builtin_exec_impl Python/bltinmodule.c:1156 (python+0x36f006) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #85 builtin_exec Python/clinic/bltinmodule.c.h:560 (python+0x36f006) #86 cfunction_vectorcall_FASTCALL_KEYWORDS Objects/methodobject.c:452 (python+0x203bd9) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #87 _PyObject_VectorcallTstate Include/internal/pycore_call.h:168 (python+0x14f921) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #88 PyObject_Vectorcall Objects/call.c:327 (python+0x14f921) #89 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1375 (python+0x8bfa8) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #90 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x382348) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #91 _PyEval_Vector Python/ceval.c:1903 (python+0x382348) #92 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd3b) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #93 _PyVectorcall_Call Objects/call.c:273 (python+0x152137) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #94 _PyObject_Call Objects/call.c:348 (python+0x1526f1) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #95 PyObject_Call Objects/call.c:373 (python+0x1526f1) #96 pymain_run_module Modules/main.c:337 (python+0x48ee2c) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #97 pymain_run_python Modules/main.c:673 (python+0x48fb8c) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #98 Py_RunMain Modules/main.c:760 (python+0x491042) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) #99 pymain_main Modules/main.c:790 (python+0x491042) #100 Py_BytesMain Modules/main.c:814 (python+0x491042) #101 main Programs/python.c:15 (python+0x85ce2) (BuildId: 53ed23022782f7933a3af0cc0267268b7d97fe42) SUMMARY: ThreadSanitizer: data race Objects/exceptions.c:524 in PyException_GetTraceback ================== ``` The fix here is to set the traceback of the exception while holding the critical section so it should use `PyException_SetTraceback` API. <!-- gh-linked-prs --> ### Linked PRs * gh-131406 * gh-131447 <!-- /gh-linked-prs -->
74b87515a72a2b7a6e601423f4b3b19b6566377f
61b4b2c57c9327273f2e306bafa23cf2c70eac8e
python/cpython
python__cpython-131370
# Encoding alias csEUCKR not supported # Bug report ### Bug description: The encoding 'csEUCKR' has been spotted in emails, and has been supported by Java since at least version 8 [1] It would be good if this could be added to the list of encoding aliases as an alias for euc_kr [1] https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131370 <!-- /gh-linked-prs -->
7558980a18b5573aac19b37535780a02bf918f89
74b87515a72a2b7a6e601423f4b3b19b6566377f
python/cpython
python__cpython-131554
# Add more tests for zero-sized bytes objects in `capi` tests # Bug report Quoting @picnixz: https://github.com/python/cpython/pull/131343#issuecomment-2729251433 > We could add more 0-size bytes tests in other functions as well I think. For instance `PyBytes_FromObject(b'')` is not tested. PRs are welcome! <!-- gh-linked-prs --> ### Linked PRs * gh-131554 * gh-131601 * gh-131629 * gh-134234 * gh-134378 * gh-134379 * gh-134458 * gh-134489 * gh-134490 <!-- /gh-linked-prs -->
f3bf304c2799c31c045033f22db7eb8766a5f939
bc26f95e8ff60ccca9818ca8522d2d0cde1b55fb
python/cpython
python__cpython-131340
# PyBytes_Size test for a zero-size bytes object `test.test_capi.test_bytes.CAPITest.test_size` that test `PyBytes_Size()` does not check for a zero-size bytes object. <!-- gh-linked-prs --> ### Linked PRs * gh-131340 * gh-131343 * gh-131344 <!-- /gh-linked-prs -->
3ae67ba97e88d6f066a5b6f0c809f57fe4a1ecbe
cf288e3c250f5538aa632cc46ce960681efec2ae
python/cpython
python__cpython-134336
# Stack overflow test errors in Alpine after GH-130398 # Bug report ### Bug description: After GH-130398 (014223649) was applied, `test.test_dynamic.RebindBuiltinsTests.test_load_global_specialization_failure_keeps_oparg` and `test.test_functools.TestLRUC.test_lru_recursion` fail with `RecursionError: Stack overflow (used 96 kB) while calling a Python object` on Alpine linux with python compiled with musl. I don't know the significance of this; the tests were already skipped on wasi and/or emscripten before that commit, which also use musl. However, the fact that a stack overflow happens where one did not previously happen is worrisome for the stability of python on Alpine. Let me know if there is any debugging assistance I can provide. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-134336 * gh-137175 <!-- /gh-linked-prs -->
1e9b8f2f8512ca4ede6ca24113a70e13c9a7cf6b
7040aa54f14676938970e10c5f74ea93cd56aa38
python/cpython
python__cpython-132232
# ctypes resize and byref/addressof is not thread-safe under free-threaded build # Bug report ### Bug description: I'm reviewing the https://github.com/python/cpython/blob/main/Modules/_ctypes/callproc.c. I believe I found a possible UB if `resize` and `byref`/`addressof` are used from different threads without any locking (AFAIU it is valid for free-threaded build and not for GIL-enabled). `resize` does `realloc` - https://github.com/python/cpython/blob/d07e9ebbe89ce701e73d25777ae057da8dffd506/Modules/_ctypes/callproc.c#L1934-L1938 After `realloc` the old value of `obj->b_ptr` is no longer valid, and any access to it is UB. If another thread calls `addressof` https://github.com/python/cpython/blob/d07e9ebbe89ce701e73d25777ae057da8dffd506/Modules/_ctypes/callproc.c#L1847 or `byref` https://github.com/python/cpython/blob/d07e9ebbe89ce701e73d25777ae057da8dffd506/Modules/_ctypes/callproc.c#L1827, it may potentially get UB under heavy contention (I believe it is zero or less real cases so far). Should we protect them with `LOCK_PTR`? ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-132232 <!-- /gh-linked-prs -->
d47584aae6fab1b767e2d2ea6611b9c0c3ff36e2
a26d58ce5242022c6ac2c8e408cf95eb5383a8e2
python/cpython
python__cpython-131334
# Cannot include `cpython/Include/internal/pycore_optimizer.h` in C++ extension due to use of protected C++ keyword "not" # Bug report ### Bug description: The code in `cpython/Include/internal/pycore_optimizer.h` causing problems ```C typedef struct { uint8_t tag; bool not; uint16_t value; } JitOptTruthiness; ``` - PR which created the issue: #130659 ### CPython versions tested on: 3.14 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-131334 <!-- /gh-linked-prs -->
883c2f682bab38344bf8c2bc345d52a9325543cc
844765b20f993e69fd6b7b70341f636fb84b473d
python/cpython
python__cpython-131328
# `winsound.SND_APPLICATION` is not documented `winsound.SND_APPLICATION` exists for a very long time but it's not documented unlike other `winsound.SND_*` consts, so I think we should document it. <!-- gh-linked-prs --> ### Linked PRs * gh-131328 * gh-131329 * gh-131330 <!-- /gh-linked-prs -->
bf4c1bf344ed1f80c4e8f4fd5b1a8f0e0858777e
9b6cef0f5dcb309096a68fdd04158e0e1313e8ec
python/cpython
python__cpython-131376
# data race while running `test_asyncio.test_sendfile` in TSAN TSAN output: ```console ❯ env TSAN_OPTIONS="halt_on_error=1" ./python -m test test_asyncio.test_sendfile -j 4 -F Using random seed: 1915823234 0:00:00 load avg: 5.66 Run tests in parallel using 4 worker processes 0:00:06 load avg: 5.53 [ 1/1] test_asyncio.test_sendfile worker non-zero exit code (Exit code 66) ================== WARNING: ThreadSanitizer: data race (pid=93940) Read of size 8 at 0x7f082d0cf000 by main thread: #0 sendmsg ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:3223 (libtsan.so.2+0x69dd9) (BuildId: 38097064631f7912bd33117a9c83d08b42e15571) #1 sock_sendmsg_impl Modules/socketmodule.c:4755 (_socket.cpython-314t-x86_64-linux-gnu.so+0x16b16) (BuildId: 73e0b0e9f457718295725baa7ce1dda77cb843a0) #2 sock_call_ex Modules/socketmodule.c:996 (_socket.cpython-314t-x86_64-linux-gnu.so+0x16b16) #3 sock_call Modules/socketmodule.c:1048 (_socket.cpython-314t-x86_64-linux-gnu.so+0x16b16) #4 sock_sendmsg Modules/socketmodule.c:4929 (_socket.cpython-314t-x86_64-linux-gnu.so+0x16b16) #5 method_vectorcall_VARARGS Objects/descrobject.c:324 (python+0x16edd3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #6 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x14f931) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #7 PyObject_Vectorcall Objects/call.c:327 (python+0x14f931) #8 _PyEval_EvalFrameDefault Python/generated_cases.c.h:3837 (python+0x8bba6) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #9 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #10 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #11 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #12 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x155808) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #13 method_vectorcall Objects/classobject.c:72 (python+0x155808) #14 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x3ae7df) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #15 context_run Python/context.c:728 (python+0x3ae7df) #16 cfunction_vectorcall_FASTCALL_KEYWORDS Objects/methodobject.c:452 (python+0x203be9) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #17 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #18 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #19 PyObject_Call Objects/call.c:373 (python+0x152701) #20 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #21 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #22 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #23 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #24 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x15568d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #25 method_vectorcall Objects/classobject.c:94 (python+0x15568d) #26 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #27 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #28 PyObject_Call Objects/call.c:373 (python+0x152701) #29 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #30 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #31 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #32 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #33 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151dae) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #34 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520c3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #35 slot_tp_call Objects/typeobject.c:10058 (python+0x27afd3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #36 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14eaa2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #37 _PyObject_VectorcallTstate Include/internal/pycore_call.h:165 (python+0x14fa28) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #38 _PyObject_VectorcallTstate Include/internal/pycore_call.h:152 (python+0x14fa28) #39 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa28) #40 _PyEval_EvalFrameDefault Python/generated_cases.c.h:3837 (python+0x8bba6) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #41 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #42 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #43 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #44 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x15568d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #45 method_vectorcall Objects/classobject.c:94 (python+0x15568d) #46 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #47 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #48 PyObject_Call Objects/call.c:373 (python+0x152701) #49 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #50 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #51 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #52 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #53 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151dae) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #54 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520c3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #55 slot_tp_call Objects/typeobject.c:10058 (python+0x27afd3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #56 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14eaa2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #57 _PyObject_VectorcallTstate Include/internal/pycore_call.h:165 (python+0x14fa28) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #58 _PyObject_VectorcallTstate Include/internal/pycore_call.h:152 (python+0x14fa28) #59 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa28) #60 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1375 (python+0x8bfa8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #61 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #62 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #63 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #64 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x15568d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #65 method_vectorcall Objects/classobject.c:94 (python+0x15568d) #66 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #67 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #68 PyObject_Call Objects/call.c:373 (python+0x152701) #69 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #70 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #71 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #72 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #73 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151dae) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #74 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520c3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #75 slot_tp_call Objects/typeobject.c:10058 (python+0x27afd3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #76 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14eaa2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #77 _PyObject_VectorcallTstate Include/internal/pycore_call.h:165 (python+0x14fa28) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #78 _PyObject_VectorcallTstate Include/internal/pycore_call.h:152 (python+0x14fa28) #79 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa28) #80 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1375 (python+0x8bfa8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #81 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381684) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #82 _PyEval_Vector Python/ceval.c:1903 (python+0x381684) #83 PyEval_EvalCode Python/ceval.c:831 (python+0x381684) #84 builtin_exec_impl Python/bltinmodule.c:1165 (python+0x36e8e6) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #85 builtin_exec Python/clinic/bltinmodule.c.h:560 (python+0x36e8e6) #86 cfunction_vectorcall_FASTCALL_KEYWORDS Objects/methodobject.c:452 (python+0x203be9) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #87 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x14f931) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #88 PyObject_Vectorcall Objects/call.c:327 (python+0x14f931) #89 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1375 (python+0x8bfa8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #90 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #91 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #92 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #93 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #94 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #95 PyObject_Call Objects/call.c:373 (python+0x152701) #96 pymain_run_module Modules/main.c:337 (python+0x48e95c) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #97 pymain_run_python Modules/main.c:673 (python+0x48f6bc) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #98 Py_RunMain Modules/main.c:760 (python+0x490b72) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #99 pymain_main Modules/main.c:790 (python+0x490b72) #100 Py_BytesMain Modules/main.c:814 (python+0x490b72) #101 main Programs/python.c:15 (python+0x85ce2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) Previous write of size 8 at 0x7f082d0cf000 by thread T3: #0 memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:115 (libtsan.so.2+0x8bd30) (BuildId: 38097064631f7912bd33117a9c83d08b42e15571) #1 memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:107 (libtsan.so.2+0x8bd30) #2 memcpy /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29 (python+0x4e8064) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #3 _buffered_readinto_generic Modules/_io/bufferedio.c:1132 (python+0x4e8064) #4 _io__Buffered_readinto_impl Modules/_io/bufferedio.c:1174 (python+0x4e88a2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #5 _io__Buffered_readinto Modules/_io/clinic/bufferedio.c.h:750 (python+0x4e88a2) #6 cfunction_vectorcall_O Objects/methodobject.c:523 (python+0x204766) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #7 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #8 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #9 PyObject_Call Objects/call.c:373 (python+0x152701) #10 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #11 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #12 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #13 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #14 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x155808) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #15 method_vectorcall Objects/classobject.c:72 (python+0x155808) #16 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #17 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #18 PyObject_Call Objects/call.c:373 (python+0x152701) #19 thread_run Modules/_threadmodule.c:351 (python+0x537705) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #20 pythread_wrapper Python/thread_pthread.h:242 (python+0x46efc9) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) Thread T3 'asyncio_0' (tid=94001, running) created by main thread at: #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so.2+0x5ac1a) (BuildId: 38097064631f7912bd33117a9c83d08b42e15571) #1 do_start_joinable_thread Python/thread_pthread.h:289 (python+0x46f45e) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #2 PyThread_start_joinable_thread Python/thread_pthread.h:313 (python+0x46f45e) #3 ThreadHandle_start Modules/_threadmodule.c:436 (python+0x538a88) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #4 do_start_new_thread Modules/_threadmodule.c:1821 (python+0x538a88) #5 thread_PyThread_start_joinable_thread Modules/_threadmodule.c:1944 (python+0x5393a1) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #6 cfunction_call Objects/methodobject.c:551 (python+0x203de6) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #7 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14eaa2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #8 _PyObject_VectorcallTstate Include/internal/pycore_call.h:165 (python+0x14fa28) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #9 _PyObject_VectorcallTstate Include/internal/pycore_call.h:152 (python+0x14fa28) #10 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa28) #11 _PyEval_EvalFrameDefault Python/generated_cases.c.h:3012 (python+0x8d3aa) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #12 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #13 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #14 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #15 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x15568d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #16 method_vectorcall Objects/classobject.c:94 (python+0x15568d) #17 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #18 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #19 PyObject_Call Objects/call.c:373 (python+0x152701) #20 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #21 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x18ceb4) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #22 gen_send_ex2 Objects/genobject.c:255 (python+0x18ceb4) #23 PyGen_am_send Objects/genobject.c:290 (python+0x18ceb4) #24 PyIter_Send Objects/abstract.c:2927 (python+0x11eb9e) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #25 task_step_impl Modules/_asynciomodule.c:3107 (_asyncio.cpython-314t-x86_64-linux-gnu.so+0x174e9) (BuildId: 164fd5a36b46f7b2595be1a06a2a688717176ee8) #26 task_step Modules/_asynciomodule.c:3447 (_asyncio.cpython-314t-x86_64-linux-gnu.so+0x19baa) (BuildId: 164fd5a36b46f7b2595be1a06a2a688717176ee8) #27 TaskStepMethWrapper_call Modules/_asynciomodule.c:2105 (_asyncio.cpython-314t-x86_64-linux-gnu.so+0x1ad79) (BuildId: 164fd5a36b46f7b2595be1a06a2a688717176ee8) #28 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14eaa2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #29 _PyObject_VectorcallTstate Include/internal/pycore_call.h:165 (python+0x3ae9e7) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #30 context_run Python/context.c:728 (python+0x3ae9e7) #31 cfunction_vectorcall_FASTCALL_KEYWORDS Objects/methodobject.c:452 (python+0x203be9) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #32 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #33 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #34 PyObject_Call Objects/call.c:373 (python+0x152701) #35 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #36 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #37 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #38 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #39 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x15568d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #40 method_vectorcall Objects/classobject.c:94 (python+0x15568d) #41 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #42 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #43 PyObject_Call Objects/call.c:373 (python+0x152701) #44 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #45 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #46 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #47 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #48 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151dae) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #49 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520c3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #50 slot_tp_call Objects/typeobject.c:10058 (python+0x27afd3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #51 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14eaa2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #52 _PyObject_VectorcallTstate Include/internal/pycore_call.h:165 (python+0x14fa28) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #53 _PyObject_VectorcallTstate Include/internal/pycore_call.h:152 (python+0x14fa28) #54 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa28) #55 _PyEval_EvalFrameDefault Python/generated_cases.c.h:3837 (python+0x8bba6) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #56 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #57 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #58 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #59 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x15568d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #60 method_vectorcall Objects/classobject.c:94 (python+0x15568d) #61 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #62 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #63 PyObject_Call Objects/call.c:373 (python+0x152701) #64 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #65 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #66 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #67 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #68 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151dae) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #69 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520c3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #70 slot_tp_call Objects/typeobject.c:10058 (python+0x27afd3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #71 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14eaa2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #72 _PyObject_VectorcallTstate Include/internal/pycore_call.h:165 (python+0x14fa28) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #73 _PyObject_VectorcallTstate Include/internal/pycore_call.h:152 (python+0x14fa28) #74 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa28) #75 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1375 (python+0x8bfa8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #76 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #77 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #78 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #79 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x15568d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #80 method_vectorcall Objects/classobject.c:94 (python+0x15568d) #81 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #82 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #83 PyObject_Call Objects/call.c:373 (python+0x152701) #84 _PyEval_EvalFrameDefault Python/generated_cases.c.h:2424 (python+0x8f52d) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #85 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #86 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #87 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #88 _PyObject_VectorcallDictTstate Objects/call.c:135 (python+0x151dae) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #89 _PyObject_Call_Prepend Objects/call.c:504 (python+0x1520c3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #90 slot_tp_call Objects/typeobject.c:10058 (python+0x27afd3) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #91 _PyObject_MakeTpCall Objects/call.c:242 (python+0x14eaa2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #92 _PyObject_VectorcallTstate Include/internal/pycore_call.h:165 (python+0x14fa28) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #93 _PyObject_VectorcallTstate Include/internal/pycore_call.h:152 (python+0x14fa28) #94 PyObject_Vectorcall Objects/call.c:327 (python+0x14fa28) #95 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1375 (python+0x8bfa8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #96 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381684) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #97 _PyEval_Vector Python/ceval.c:1903 (python+0x381684) #98 PyEval_EvalCode Python/ceval.c:831 (python+0x381684) #99 builtin_exec_impl Python/bltinmodule.c:1165 (python+0x36e8e6) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #100 builtin_exec Python/clinic/bltinmodule.c.h:560 (python+0x36e8e6) #101 cfunction_vectorcall_FASTCALL_KEYWORDS Objects/methodobject.c:452 (python+0x203be9) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #102 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x14f931) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #103 PyObject_Vectorcall Objects/call.c:327 (python+0x14f931) #104 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1375 (python+0x8bfa8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #105 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x381cc8) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #106 _PyEval_Vector Python/ceval.c:1903 (python+0x381cc8) #107 _PyFunction_Vectorcall Objects/call.c:413 (python+0x14fd4b) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #108 _PyVectorcall_Call Objects/call.c:273 (python+0x152147) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #109 _PyObject_Call Objects/call.c:348 (python+0x152701) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #110 PyObject_Call Objects/call.c:373 (python+0x152701) #111 pymain_run_module Modules/main.c:337 (python+0x48e95c) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #112 pymain_run_python Modules/main.c:673 (python+0x48f6bc) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #113 Py_RunMain Modules/main.c:760 (python+0x490b72) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) #114 pymain_main Modules/main.c:790 (python+0x490b72) #115 Py_BytesMain Modules/main.c:814 (python+0x490b72) #116 main Programs/python.c:15 (python+0x85ce2) (BuildId: 6e4283fbb4478682ac711d38bd84278fe71b8bf2) SUMMARY: ThreadSanitizer: data race Modules/socketmodule.c:4755 in sock_sendmsg_impl ================== Kill <WorkerThread #2 running test=test_asyncio.test_sendfile pid=93939 time=6.5 sec> process group Kill <WorkerThread #3 running test=test_asyncio.test_sendfile pid=93942 time=6.5 sec> process group Kill <WorkerThread #4 running test=test_asyncio.test_sendfile pid=93941 time=6.5 sec> process group ``` The race happens in `test_sendfile_force_fallback` in `test_sendfile` because when the fallback implementation is used, it uses `file.readinto` [^1] in a thread pool and while writing it uses the buffer protocol which seems to trigger the TSAN warning in `_buffered_readinto_generic` [^2]. The buffer protocol isn't safe because the object is not locked when writing through the exported buffer. I am not sure how to fix this without avoiding the buffer protocol. [^1]: https://github.com/python/cpython/blob/3185e3115c918ec189e16cf9f5b51a13a0146556/Lib/asyncio/base_events.py#L965 [^2]: https://github.com/python/cpython/blob/3185e3115c918ec189e16cf9f5b51a13a0146556/Modules/_io/bufferedio.c#L1128-L1135 <!-- gh-linked-prs --> ### Linked PRs * gh-131376 * gh-131377 * gh-131378 <!-- /gh-linked-prs -->
94f4d87aeb4d2d7bddcb4c3aad4f62a727ac91ee
46e88540e6f15a461d6f91e45d1c68819a7f074c
python/cpython
python__cpython-131324
# Handle error scenarios of HACL* functions This is a follow-up on https://github.com/python/cpython/pull/130960#issuecomment-2726897435: >For all hash algorithms (NEW with this PR): malloc, malloc_with_params_and_key, malloc_with_key: may return NULL (out of memory) copy: may return NULL (out of memory) Full list from https://github.com/python/cpython/pull/130960#issuecomment-2715631704 > For Hacl_Streaming_HMAC: > > * malloc may return OutOfMemory, InvalidAlgorithm (e.g. requesting Blake2b_256 on an ARM machine), or Success > * reset may return InvalidLength (if trying to reset the state with a key of different length, this is not supported), or Success > * update: MaximumLengthExceeded or Success > * digest: OutOfMemory or Success > * copy: may return NULL (indicates out of memory) > > For all hash algorithms (_NEW with this PR_): > > * malloc, malloc_with_params_and_key, malloc_with_key: may return NULL (out of memory) > * copy: may return NULL (out of memory) > > For SHA3/Keccak only: > > * digest may return InvalidAlgorithm (if the algorithm is shake) > * squeeze may return InvalidAlgorithm (if the algorithm is not shake) > > I think all of these can be handled as a followup, I just thought it would be good to have it in writing here so that you can decide which of these are worth checking for. The reason I brought up other hash algorithms is that, since you requested (or maybe @picnixz ?) proper out of memory handling in HACL*, we now may return NULL for other algorithms (like hash algorithms), meaning that this PR will introduce new possibly-NULL return values as a side-effect of updating the vendored copy of HACL*. > > For the record, Python ignores MaximumLengthExceeded on the basis that this cannot happen in practice. <!-- gh-linked-prs --> ### Linked PRs * gh-131324 * gh-135291 <!-- /gh-linked-prs -->
261633bd3f48607478f50d12d8025cd4bb36f6f4
de8890f5ab1c1e767029d46c20f513beefc47b18
python/cpython
python__cpython-131312
# Possible memory leak in _ctypes/PyCStructUnionType_update_stginfo on fail path # Bug report ### Bug description: 1. [x] I have found that `layout_func `may leak when creating of `kwnames `fails: https://github.com/python/cpython/blob/e82c2ca2a59235bc1965b259f4421635861e0470/Modules/_ctypes/stgdict.c#L260-L270 But on error it doesn't clear `layout_func`: https://github.com/python/cpython/blob/e82c2ca2a59235bc1965b259f4421635861e0470/Modules/_ctypes/stgdict.c#L665-L671 2. [x] `StructParam_traverse` should VISIT `keep` member: https://github.com/python/cpython/blob/e82c2ca2a59235bc1965b259f4421635861e0470/Modules/_ctypes/_ctypes.c#L412-L416 3. [x] `PyCSimpleType_init` should DECREF `swapped` local variable if no StgInfo: https://github.com/python/cpython/blob/e82c2ca2a59235bc1965b259f4421635861e0470/Modules/_ctypes/_ctypes.c#L2373-L2382 4. [x] `make_funcptrtype_dict` should DECREF 'ob' local variable if no StgInfo: https://github.com/python/cpython/blob/e82c2ca2a59235bc1965b259f4421635861e0470/Modules/_ctypes/_ctypes.c#L2670-L2677 5. [x] Not memory leak, but possible crush. `Pointer_subscript` should check `Pointer_item` result before putting it to result list: https://github.com/python/cpython/blob/e82c2ca2a59235bc1965b259f4421635861e0470/Modules/_ctypes/_ctypes.c#L5650-L5653 6. [x] As discussed at gh-131312 we should split PyCStructUnionType_update_stginfo and manage `type_block` in separate function. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131312 * gh-131429 * gh-131504 <!-- /gh-linked-prs -->
812074e291d559824d496909a87fb5c26c37f60c
3453b5c1d652a0424a333332b576f9b878424061
python/cpython
python__cpython-131307
# Remove unused code related to the removed `BINARY_SUBSCR` instruction `BINARY_SUBSCR` was replaced with `BINARY_OP` and the `NB_SUBSCR` oparg in https://github.com/python/cpython/pull/129700 but there is still some code related to `BINARY_SUBSCR` that I believe can be removed. Some examples: https://github.com/python/cpython/blob/e82c2ca2a59235bc1965b259f4421635861e0470/Include/internal/pycore_code.h#L121-L125 https://github.com/python/cpython/blob/e82c2ca2a59235bc1965b259f4421635861e0470/Lib/opcode.py#L66-L68 <!-- gh-linked-prs --> ### Linked PRs * gh-131307 <!-- /gh-linked-prs -->
d07e9ebbe89ce701e73d25777ae057da8dffd506
bf4c1bf344ed1f80c4e8f4fd5b1a8f0e0858777e
python/cpython
python__cpython-132438
# Undefined references to HACL symbols when statically linking Python 3.12 # Bug report ### Bug description: I am developing an application that uses Python 3.12's static library (libpython3.12.a). Due to some restrictions, I am required to use a package manager to install Python and cannot compile it from source. Additionally, I can't use dynamic libraries, so I must link python statically. When linking libpython3.12.a to my project, I encounter undefined references to HACL (HACL*) symbols, such as: ```bash /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/libpython3.12.a(sha2module.o): in function `update_256': (.text.unlikely+0x9ea): undefined reference to `python_hashlib_Hacl_Hash_SHA2_update_256' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/libpython3.12.a(sha2module.o): in function `SHA512Type_copy': (.text.unlikely+0xcd3): undefined reference to `python_hashlib_Hacl_Hash_SHA2_copy_512' [etc.] ``` These symbols appear to be related to the HACL library, which is included in Python 3.12's development. However, I cannot locate the corresponding object files or static libraries for HACL in the Python installation provided by the package manager. I was previously using python3.11 - which worked flawlessly -, however the dev package has been removed from apt and other similar package managers. For this specific reason, I had to upgrade. A quick note, the command `nm -gA /usr/lib/x86_64-linux-gnu/*.a 2>/dev/null | grep python_hashlib_Hacl_Hash_SHA2_update_512` shows that these symbols are shipped with the static package: `/usr/lib/x86_64-linux-gnu/libpython3.12.a:sha2module.o: U python_hashlib_Hacl_Hash_SHA2_update_512`. Steps to Reproduce: 1. Install Python 3.12 using your system's package manager (e.g., `apt` on Ubuntu). 2. Attempt to statically link the Python static library `libpython3.12.a` into a C/C++ project. 3. Observe linker errors related to undefined references to HACL symbols. Expected Behavior: The static library libpython3.12.a should include all necessary dependencies, including HACL, or provide a way to link against HACL statically. Actual Behavior: The linker fails with undefined references to HACL symbols, as the required HACL objects or static libraries are not provided. Questions: 1. Are the HACL object files or static libraries supposed to be included in the Python 3.12 package from the package manager? 2. If not, is there a recommended way to obtain the necessary HACL static library for linking with libpython3.12.a? And if so, is it possible to do so without having to compile Python or any other large project? 3. Could this be an issue with the packaging of Python 3.12 in the package manager, or is it a broader issue with the static linking setup? 4. My primary goal is to link python statically. If there isn't any solution available that follows the requirements of using a package manager, are there any work arounds to bypass the linker issue? Thank you for your assistance. ### CPython versions tested on: 3.12 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-132438 * gh-133012 <!-- /gh-linked-prs -->
5f2ba152a0471f6f556ca2d9486e5ba486fcfbde
492e3e6976d05b8de1892c37c900ada23eaeaf06
python/cpython
python__cpython-131297
# clang-cl issues many warnings when building on Windows See e.g. https://github.com/python/cpython/actions/runs/13681800146/job/38255779088. I went through roughly 100 warnings to find this one https://github.com/python/cpython/issues/131020. Others are mostly benign, yet I'd like to reduce them. Since many of the warnings stem from `pythoncore`, we see them twice, because the `_freeze_module` compiles a lot of those `*.c` files, too - and in case of PGO we see them a third time in the PGUpdate phase. E.g. a bunch of warnings will disappear after the next sync with hacl-star upstream, since @msprotz thankfully already merged https://github.com/hacl-star/hacl-star/pull/1028. I think it is best to do them in small PRs per `*.c` file. Ideally, I'd like to end up with the same warning configuration as used on Linux. When I configure for clang in WSL, I get ``` CONFIGURE_CFLAGS_NODIST= -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden ``` This would currently generate even more warnings, since we currently use https://github.com/python/cpython/blob/faa80fcf46f379dd13ad2d4d2a406449d37c2d60/PCbuild/pyproject-clangcl.props#L41 So maybe I should do this after a first round of cleaning? <!-- gh-linked-prs --> ### Linked PRs * gh-131297 * gh-131299 * gh-131300 * gh-131301 * gh-131302 * gh-131303 * gh-131304 * gh-131374 * gh-131514 * gh-131584 * gh-131587 * gh-131589 * gh-131590 * gh-131593 * gh-131594 * gh-131595 * gh-131600 * gh-131604 * gh-131821 * gh-131832 * gh-131897 * gh-131900 * gh-131905 * gh-131906 * gh-133142 <!-- /gh-linked-prs -->
f104c19a94ae43f788e509019901b1f48fbd134e
faa80fcf46f379dd13ad2d4d2a406449d37c2d60
python/cpython
python__cpython-131292
# Fix compiling python_uwp.cpp with clang-cl on Windows clang-cl fails with the following error when compiling `python_uwp.cpp`: ``` 1>In file included from ..\PC\python_uwp.cpp:14: 1>In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\cppwinrt\winrt\Windows.ApplicationModel.h:9: 1>In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\cppwinrt\winrt/base.h:56: 1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\experimental/coroutine(29,2): error : The <experimental/coroutine>, <experimental/generator>, and <experimental/resumable> headers do not support Clang, but the C++20 <coroutine> header does. ``` Let's fix it using ```c #if defined(__clang__) #define _SILENCE_CLANG_COROUTINE_MESSAGE #endif ``` before including the respective header. This only happens when `IncludeUwp` is set in case of building with `build.bat` or in the Visual Studio IDE, because there always all projects are built. <!-- gh-linked-prs --> ### Linked PRs * gh-131292 <!-- /gh-linked-prs -->
ef4fe7078513c658ef8239d2e64ddc33e4c3d4c1
30d52058493e07fd1d3efea960482f4001bd2f86
python/cpython
python__cpython-131371
# Multiple tests failing when invoked directly via `./python Lib/test/...` Besides `test_pickle` reported in https://github.com/python/cpython/issues/131031, there are a few more (`test_regrtest`, `test_metaclass` and `test_pyclbr`): ```sh ~ ./python Lib/test/test_regrtest.py ... Ran 115 tests in 35.727s FAILED (failures=1, skipped=2) ``` ```sh ~ ./python Lib/test/test_metaclass.py ... Ran 1 test in 0.018s FAILED (failures=1) ``` ```sh ~ ./python Lib/test/test_pyclbr.py ... Ran 6 tests in 1.720s FAILED (failures=1, errors=1) ``` <!-- gh-linked-prs --> ### Linked PRs * gh-131371 <!-- /gh-linked-prs -->
292a7248cda89f497e06eff4aa0147d6ff22f6bb
2aab2db1461ef49b42549255af16a74b1bf8a5ef
python/cpython
python__cpython-131289
# MSVC emits warnings in non-debug builds Since https://github.com/python/cpython/pull/130398, the below warning is emitted several times in case of MSVC release (or PGO) builds: ``` Include\internal\pycore_ceval.h(209): warning C4172: returning address of local variable or temporary : here ``` So the comment in the code https://github.com/python/cpython/blob/55815a6474c59001f0230e44560341b643268e87/Include/internal/pycore_ceval.h#L202-L211 only works for debug builds. This is because in case of optimizing, MSVC is inlining `return_pointer_as_int` https://github.com/python/cpython/blob/55815a6474c59001f0230e44560341b643268e87/Include/internal/pycore_ceval.h#L196-L200 and then is "smart" enough to realize and warn about it. See here https://godbolt.org/z/ooK5Poxo3 (btw gcc or clang won't do that https://godbolt.org/z/459f6hj9G). [__declspec(noinline)](https://godbolt.org/z/Mh856qbnv) would help, but IMHO is an unneeded performance penalty. ~~I suggest to use `#pragma warning(disable:4172)` to silence the warning.~~ ~~Since this is a [code generation warning (4700-4999)](https://learn.microsoft.com/cpp/preprocessor/warning?view=msvc-170), we have to guard the whole `_Py_get_machine_stack_pointer` and cannot just place it around line 209.~~ @colesbury had a much better idea: use [_AddressOfReturnAddress](https://learn.microsoft.com/cpp/intrinsics/addressofreturnaddress?view=msvc-170) which even gets rid of UB: see https://godbolt.org/z/7c9Gq9jzM and https://github.com/llvm/llvm-project/blob/llvmorg-10.0.0-rc1/clang/lib/Basic/Stack.cpp#L24. <!-- gh-linked-prs --> ### Linked PRs * gh-131289 <!-- /gh-linked-prs -->
20098719dffe837fb0e516fbb97336e9a8e3354f
37d47d496525142d12a94fb234c8b8311292c349
python/cpython
python__cpython-131283
# Compile fails when `--enable-pystats` # Bug report ### Bug description: I've tried to compile CPython with `--enable-pystats`, but it fails ```python mkdir build && cd build ../configure --with-pydebug --enable-test-modules --enable-pystats make -j8 ... In file included from ../Include/internal/pycore_interp.h:16, from ../Include/internal/pycore_runtime.h:19, from ../Include/internal/pycore_pystate.h:11, from ../Include/internal/pycore_call.h:11, from ../Python/ceval.c:9: ../Python/generated_cases.c.h: In function ‘_PyEval_EvalFrameDefault’: ../Python/generated_cases.c.h:705:22: error: ‘BINARY_SUBSCR’ undeclared (first use in this function); did you mean ‘BINARY_SLICE’? 705 | STAT_INC(BINARY_SUBSCR, hit); | ^~~~~~~~~~~~~ ../Include/internal/pycore_code.h:362:76: note: in definition of macro ‘STAT_INC’ 362 | #define STAT_INC(opname, name) do { if (_Py_stats) _Py_stats->opcode_stats[opname].specialization.name++; } while (0) | ^~~~~~ ../Python/generated_cases.c.h:705:22: note: each undeclared identifier is reported only once for each function it appears in 705 | STAT_INC(BINARY_SUBSCR, hit); | ^~~~~~~~~~~~~ ../Include/internal/pycore_code.h:362:76: note: in definition of macro ‘STAT_INC’ 362 | #define STAT_INC(opname, name) do { if (_Py_stats) _Py_stats->opcode_stats[opname].specialization.name++; } while (0) | ^~~~~~ ``` wth gcc 14.2.0 ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131283 * gh-131369 <!-- /gh-linked-prs -->
1821f8f10c7a4a43a4fb55fe4e3da4cadfec699d
55815a6474c59001f0230e44560341b643268e87
python/cpython
python__cpython-131279
# Support building using "computed gotos" for clang-cl on Windows Per suggestion from @zooba in https://github.com/python/cpython/pull/130040#issuecomment-2714375928, don't be too fancy here: - just support a new optimizing build flag `WITH_COMPUTED_GOTOS` and keep `build.bat` out of the loop. It does not have to learn such flags. It already knows too many of them "which could just be passed through". - only test for `!= ''` rather than a specific value. - no magic defaults - explicit is better than implicit. If it is there, it's enabled, else it's disabled. - but document like `set WITH_COMPUTED_GOTOS=true` - this would give us the possibility to opt out using `WITH_COMPUTED_GOTOS=false`, should we ever enable it by default (and the user does not like our guess) <!-- gh-linked-prs --> ### Linked PRs * gh-131279 <!-- /gh-linked-prs -->
468a7aaeb4dfcd21697dfa46362b9f415b9daf1b
94f4d87aeb4d2d7bddcb4c3aad4f62a727ac91ee
python/cpython
python__cpython-131280
# Enhance `test.support.os_helper.EnvironmentVarGuard` interface # Feature or enhancement Currently, we have a lot of pattern of the form: ```py with EnvironmentVarGuard() as env: if no_c in env: env.unset(no_c) if no_d in env: env.unset(no_d) for ev in {no_a, no_b}: if ev in env: env.unset(ev) ``` I think it makes sense to have something like this: ```py with EnvironmentVarGuard() as env: env.unset(no_a, no_b, no_c, no_d) # unset many vars at once ``` or to also provide a decorator-based approach when the values to set/unset are statically known. ### Features - [x] Allow to unset multiple environment variables: `env.unset(k1, k2, ...)` Some optional features that I rejected after looking at the use cases: - [x] Allow to specify new environment variables at construction time (it could save a few lines when we're only modifying one or two envvars) [abandoned, not enough readable use cases] - [x] Add decorator-based environment guard for EnvironmentVarGuard() [abandoned for now] I plan to create a PR today or tomorrow to illustrate the new interface. EDIT: no need to the support for setting multiple variables at once because `EnvironmentVarGuard` is a mapping, so it has `.update()` which does the trick. <!-- gh-linked-prs --> ### Linked PRs * gh-131280 * gh-131409 * gh-131410 <!-- /gh-linked-prs --> See https://github.com/python/cpython/issues/131277#issuecomment-2732990999 for the version labels rationale and https://github.com/python/cpython/pull/131280#issuecomment-2732988961 for the backporte rationale.
3185e3115c918ec189e16cf9f5b51a13a0146556
9558d22ac308c102e4f843541eead2022050225e
python/cpython
python__cpython-131270
# Avoid binding functions to temporaries in `random.py` # Feature or enhancement The random module has a bunch of code that binds methods to temporary local variables like: ```python getrandbits = self.getrandbits ``` https://github.com/python/cpython/blob/55815a6474c59001f0230e44560341b643268e87/Lib/random.py#L248-L253 I think this pattern dates back to 2001 (in https://github.com/python/cpython/commit/d7b5e88e8e40b77813ceb25dc28b87d672538403). I think it was an optimization at one point, but now it's the opposite. Python optimizes method calls (in some sort since 3.7) so it's faster to use: ```python k = n.bit_length() r = self.getrandbits(k) # 0 <= r < 2**k while r >= n: r = self.getrandbits(k) return r ``` Getting rid of this pattern seems to: 1) Speed calls like `random.randint()` and `random.shuffle()` by about 10-15% 2) Avoid some contention in multithreaded code because we are able to specialize the calls to `LOAD_ATTR_METHOD_WITH_VALUES` [^1] This came up when looking at a variation of @pfmoore's code snippet: [montecarlo.py](https://gist.github.com/pfmoore/fda0ee5a6c79ad39a9c7b391861ff2fe) [^1]: I think we should be able avoid contention even with this (anti-)pattern, but I'll write that up in a separate issue. <!-- gh-linked-prs --> ### Linked PRs * gh-131270 <!-- /gh-linked-prs -->
844765b20f993e69fd6b7b70341f636fb84b473d
c83efa7a66e30276c328fa4a5f8f8d26977f3e1c
python/cpython
python__cpython-131345
# _thread.set_name(): doubt about _PYTHREAD_NAME_MAXLEN values for BSD operating systems # Bug report ## FreeBSD ### Bug description: https://github.com/python/cpython/pull/127338/commits/6088b37759f0ce6cc1414a092ee7c4814d182256 states that "FreeBSD truncates to 98 bytes silently". This figure stems from an [empirical test](https://github.com/python/cpython/pull/127338#issuecomment-2511767330), but I have reasons to doubt it reflects reality and believe the matter should be either fixed or clarified. ### User perspective On FreeBSD, `ps --libxo json -Ho tdname` returns a maximum of 19 characters, which matches `MAXCOMLEN`: ```console $ grep MAXCOMLEN /usr/include/sys/param.h * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) #define MAXCOMLEN 19 /* max command name remembered */ ``` ### System perspective Let's have a look at [FreeBSD's implementation of pthread_setname_np()](https://github.com/freebsd/freebsd-src/blob/36782aaba4f1a7d054aa405357a8fa2bc0f94eb0/lib/libthr/thread/thr_info.c#L58). For the purpose of this discussion, it can be simplified down to this: ```c int _pthread_setname_np(pthread_t thread, const char *name) { /* thr_set_name(2): The name will be silently truncated to fit into a buffer of MAXCOMLEN + 1 bytes. */ if (thr_set_name(thread->tid, name) == -1) /* this is a syscall */ res = errno; else thr_set_name_np(thread, &tmp_name); /* thread->name = *tmp_name; */ } ``` According to [thr_private.h](https://github.com/freebsd/freebsd-src/blob/36782aaba4f1a7d054aa405357a8fa2bc0f94eb0/lib/libthr/thread/thr_private.h#L578), thread->name is a simple `char *`. As to [pthread_getname_np()](https://github.com/freebsd/freebsd-src/blob/36782aaba4f1a7d054aa405357a8fa2bc0f94eb0/lib/libthr/thread/thr_info.c#L106), it boils down to: ```c strlcpy(buf, thread->name, len); ``` Otherly put, `pthread_setname_np()` sets the thread name through a syscall that truncates to MAXCOMLEN=19 chars and keeps an untouched copy of it. However, that untouched copy may get truncated to the length passed to `pthread_getname_np()`. Here, I am tempted to say that 98-char limitation actually stems from this: https://github.com/python/cpython/blob/55815a6474c59001f0230e44560341b643268e87/Modules/_threadmodule.c#L2408-L2410 Working with a 100-char array implies a 99-character string. Not sure how we get from 99 to 98, but I agree with @vstinner that: > There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors. ### Third perspective Before diving into FreeBSD's libpthread implementation, I had a look at [sys/procfs.h](https://github.com/freebsd/freebsd-src/blob/36782aaba4f1a7d054aa405357a8fa2bc0f94eb0/sys/sys/procfs.h#L74-L90): ```c #define PRFNAMESZ 16 /* Maximum command length saved */ #define PRARGSZ 80 /* Maximum argument bytes saved */ #define PRPSINFO_VERSION 1 /* Current version of prpsinfo_t */ typedef struct prpsinfo { int pr_version; /* Version number of struct (1) */ size_t pr_psinfosz; /* sizeof(prpsinfo_t) (1) */ char pr_fname[PRFNAMESZ+1]; /* Command name, null terminated (1) */ char pr_psargs[PRARGSZ+1]; /* Arguments, null terminated (1) */ pid_t pr_pid; /* Process ID (1a) */ } prpsinfo_t; typedef struct thrmisc { char pr_tname[MAXCOMLEN+1]; /* Thread name, null terminated (1) */ u_int _pad; /* Convenience pad, 0-filled (1) */ } thrmisc_t; ``` Although `struct thrmisc` confirms my hunch that thread names are truncated to MAXCOMLEN=19 chars, I noticed that, within `struct prpsinfo`, `PRFNAMESZ+1` + `PRARGSZ+1` = 16+1 + 80+1 = 98. This was a little scary because that would imply null bytes conveniently appearing thanks to alignment (or similar shenanigans). ### Kernel perspective The [implementation of the thr_set_name() syscall](https://github.com/freebsd/freebsd-src/blob/36782aaba4f1a7d054aa405357a8fa2bc0f94eb0/sys/kern/kern_thr.c#L577-L610) confirms the FreeBSD kernel truncates thread names to `MAXCOMLEN` chars (specifically, it tries to copy the entire name then handles `ENAMETOOLONG`). ### Conclusion Although I am not 100% sure of why we got 98 instead of 99 or 100, it seems 19 would be a better choice. ## OpenBSD ### Bug description: The current implementation mentions FreeBSD and NetBSD but not OpenBSD. ### System perspective The [librthread implementation of pthread_set_name_np() and pthread_get_name_np()](https://github.com/openbsd/src/blob/d50894551f0651eae99e51018017091ca2c37212/lib/librthread/rthread_np.c#L39-L60) invokes the `setthrname` and `getthrname` syscalls. getthrname(2) says: > ``` > setthrname() may return the following errors: > > [EINVAL] The name argument pointed to a string that was too > long. Thread names are limited to MAXCOMLEN > characters, currently 23. > ``` MAXCOMLEN is indeed 23: ``` /usr/include/sys/param.h:#define MAXCOMLEN _MAXCOMLEN-1 /* max command name remembered, without NUL */ /usr/include/sys/syslimits.h:#define _MAXCOMLEN 24 /* includes NUL */ ``` ### Conclusion `configure.ac` should have an extra line: ```bash OpenBSD*) _PYTHREAD_NAME_MAXLEN=23;; ``` ## NetBSD ### Bug description The current implementation: ```bash NetBSD*) _PYTHREAD_NAME_MAXLEN=31;; ``` ... is seemingly correct from the system (libpthread) perspective but it does not take the kernel perspective into account. ### System perspective The [implementation of pthread_setname_np()](https://github.com/NetBSD/src/blob/2962f5a0a20b26fe8b38f64d9ec70c60ad9128fe/lib/libpthread/pthread.c#L825-L855) returns `EINVAL` if `snprintf()` reports it had to truncate the resulting name to `PTHREAD_MAX_NAMELEN_NP` chars. PTHREAD_MAX_NAMELEN_NP is 32. `/usr/include/pthread.h:#define PTHREAD_MAX_NAMELEN_NP 32` pthread_setname_np() then calls _lwp_setname(), which is a syscall. ### Kernel perspective The [implementation of the _lwp_setname() syscall](https://github.com/NetBSD/src/blob/2962f5a0a20b26fe8b38f64d9ec70c60ad9128fe/sys/kern/sys_lwp.c#L663-L709) works with a NULL-terminated MAXCOMLEN-long string. MAXCOMLEN is 16. `/usr/include/sys/param.h:#define MAXCOMLEN 16 /* max command name remembered */` Otherly put, thread names cannot exceed 15 characters on NetBSD. ### Conclusion The correct implementation should be: ```bash NetBSD*) _PYTHREAD_NAME_MAXLEN=15;; ``` ## CPython versions tested on: CPython main branch ## Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-131345 * gh-131528 <!-- /gh-linked-prs -->
aabab76c8af3e2efb6c5d55bd0274c7e0bc029dd
b2ed7a6d6aae9860110f6ec495dc88dde670cfe4
python/cpython
python__cpython-131431
# test_timerfd_negative hangs indefinitely, causes system freeze on NetBSD # Bug report ### Bug description: When running the `test_timerfd_negative` test from `test_os.TimerfdTests`, the test process hangs indefinitely, cannot be interrupted with Control-C or Control-D, and eventually causes the entire system to freeze. ### Configuration: ``` ./configure --with-pydebug ``` ### Test ``` ./python -m test test_os -m test_timerfd_negative -v ``` Output: ```python == CPython 3.14.0a6+ (heads/main:26511993e63, Mar 15 2025, 00:00:15) [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_20759æ == 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: 886729535 0:00:00 load avg: 0.19 Run 1 test sequentially in a single process 0:00:00 load avg: 0.19 [1/1] test_os test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) ... test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=0, initial=-1, interval=0) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=1, initial=-1, interval=0) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=3, initial=-1, interval=0) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=0, initial=1, interval=-1) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=1, initial=1, interval=-1) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=3, initial=1, interval=-1) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=0, initial=-1, interval=-1) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=1, initial=-1, interval=-1) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=3, initial=-1, interval=-1) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=0, initial=-0.1, interval=0) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=1, initial=-0.1, interval=0) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=3, initial=-0.1, interval=0) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=0, initial=1, interval=-0.1) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=1, initial=1, interval=-0.1) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=3, initial=1, interval=-0.1) ... FAIL test_timerfd_negative (test.test_os.TimerfdTests.test_timerfd_negative) (flags=0, initial=-0.1, interval=-0.1) ... FAIL ``` OS: `NetBSD-10.0-amd64` ### CPython versions tested on: CPython main branch, 3.13, 3.14 ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-131431 * gh-131451 <!-- /gh-linked-prs -->
8ad4646c675211dc1df0254a3160f50a18e4c6c3
3118693a1a3db0da96c565a2de015a806c892625
python/cpython
python__cpython-131272
# Please upgrade bundled Expat to 2.7.0 (e.g. for the fix to CVE-2024-8176) # Bug report ### Bug description: Hi! 👋 Please upgrade bundled Expat to 2.7.0 (e.g. for the fix to CVE-2024-8176). - GitHub release: https://github.com/libexpat/libexpat/releases/tag/R_2_7_0 - Change log: https://github.com/libexpat/libexpat/blob/R_2_7_0/expat/Changes - Bonus: Blog post [Recursion kills: The story behind CVE-2024-8176 in libexpat](https://blog.hartwork.org/posts/expat-2-7-0-released/) The CPython issue for previous 2.6.4 was #126623 and the related merged main pull request was #126792, 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, 3.11, 3.12, 3.13, 3.14, CPython main branch ### Operating systems tested on: Linux, macOS, Windows, Other <!-- gh-linked-prs --> ### Linked PRs * gh-131272 * gh-131359 * gh-131360 * gh-131361 * gh-131362 * gh-131363 * gh-131364 <!-- /gh-linked-prs -->
bb0268f60dfe903a9bdb8d84104247a9318c6b18
978e37bb5f979cccce36613637ac2d94b43c71b2
python/cpython
python__cpython-131276
# test_webbrowser failure on MacOS if BROWSER set to "open" # Bug report ### Bug description: I just noticed a new-to-me failure on `main` for the `test_webbrowser` unit test. Here's the rundown: ```pytb % ./python.exe -E -m test test_webbrowser Using random seed: 3730311481 Raised RLIMIT_NOFILE: 256 -> 1024 0:00:00 load avg: 4.38 Run 1 test sequentially in a single process 0:00:00 load avg: 4.38 [1/1] test_webbrowser test test_webbrowser failed -- Traceback (most recent call last): File "/Users/skip/src/python/cpython/Lib/test/test_webbrowser.py", line 334, in test_default assert isinstance(browser, webbrowser.MacOSXOSAScript) ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError 0:00:00 load avg: 4.38 [1/1/1] test_webbrowser failed (1 failure) == Tests result: FAILURE == 1 test failed: test_webbrowser Total duration: 48 ms Total tests: run=48 failures=1 skipped=4 Total test files: run=1/1 failed=1 Result: FAILURE % env | grep BROWSER BROWSER=open % unset BROWSER % ./python.exe -E -m test test_webbrowser Using random seed: 2541583609 Raised RLIMIT_NOFILE: 256 -> 1024 0:00:00 load avg: 3.19 Run 1 test sequentially in a single process 0:00:00 load avg: 3.19 [1/1] test_webbrowser 0:00:00 load avg: 3.19 [1/1] test_webbrowser passed == Tests result: SUCCESS == 1 test OK. Total duration: 50 ms Total tests: run=48 skipped=4 Total test files: run=1/1 Result: SUCCESS ``` In short, if the `BROWSER` environment variable is set to `open`, the test fails. (This didn't used to be the case as far as I can recall. The entire test suite passed a couple days ago with the expected skips, no failures.) If I unset `BROWSER`, the test succeeds. I suspect this commit is the culprit: `96492785b202a92af1b71f8c011ea839ca3ebb07` ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-131276 <!-- /gh-linked-prs --> Feature was introduced in https://github.com/python/cpython/pull/130535.
9b6cef0f5dcb309096a68fdd04158e0e1313e8ec
3185e3115c918ec189e16cf9f5b51a13a0146556
python/cpython
python__cpython-131250
# Our internal headers are far too interlinked Adding a small feature like https://github.com/python/cpython/pull/131198#discussion_r1994046212 becomes a complicated puzzle of moving functions and structs between header files to avoid cycles. I was ultimately defeated in this case. This is a bit silly. We should break up these dependencies, by breaking headers into structs and code. Code depends on data, and headers that depend on some structs, but not the code, can import only the struct definitions. Breaking headers into smaller, more self contained chunks would also help. As an example of the problem, to use `_PyThreadState_GET()` one must import `pycore_pystate.h` but that imports `pycore_runtime.h` which imports **nineteen** other "core" header files! <!-- gh-linked-prs --> ### Linked PRs * gh-131250 * gh-131257 * gh-131351 * gh-131352 * gh-131356 * gh-131472 * gh-131480 * gh-131481 * gh-131482 * gh-131483 * gh-131486 * gh-131495 * gh-131545 * gh-131549 * gh-131553 * gh-131560 * gh-131571 <!-- /gh-linked-prs -->
a1aeec61c4321ba9a6966109343bd88dcf9cb26a
3ae67ba97e88d6f066a5b6f0c809f57fe4a1ecbe
python/cpython
python__cpython-131218
# Allow to generate multiple UUIDs at once via CLI # Feature or enhancement ### Proposal: Add `--count` to the main() of the uuid module. Sometimes you need more than one UUID. In order to print 42 UUIDs, run `python -m uuid --count 42` Inspired by https://www.man7.org/linux/man-pages/man1/uuidgen.1.html ### 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-131218 <!-- /gh-linked-prs -->
52b5eb95b770fa00ebbd449ba40cab4a0e7c7df7
4b3d5b604210f68005ef64d5346ca169385f5acf
python/cpython
python__cpython-131235
# `test_keywords` in `test_popen` can be improved # Bug report `test_keywords` here: https://github.com/python/cpython/blob/7fd61607cd28ec466717c78adfb1eb5b63add1f0/Lib/test/test_popen.py#L65-L68 does not assert anything. I propose to use an example similar to this one: https://github.com/python/cpython/blob/7fd61607cd28ec466717c78adfb1eb5b63add1f0/Lib/test/test_popen.py#L57-L59 and at least assert that the expected program executed and that `f` is still not closed in `with` body. I have a PR ready. <!-- gh-linked-prs --> ### Linked PRs * gh-131235 * gh-131240 * gh-131241 <!-- /gh-linked-prs -->
fc07f863ee2a942dd96e1ca9edf049603fbb574e
2250ab6a13dd269b738cfd391851933fca75533d
python/cpython
python__cpython-131416
# return-in-finally in multiprocessing/connection.py https://github.com/python/cpython/blob/7fd61607cd28ec466717c78adfb1eb5b63add1f0/Lib/multiprocessing/connection.py#L330C1-L340C68 This is clearly a bug, because the `except:` clause contains a naked `raise`, i.e., asks for the exception to propagate on. But the return in finally swallows that exception. ``` try: ... except: ov.cancel() raise finally: nread, err = ov.GetOverlappedResult(True) if err == 0: f = io.BytesIO() f.write(ov.getbuffer()) return f elif err == _winapi.ERROR_MORE_DATA: return self._get_more_data(ov, maxsize) ``` <!-- gh-linked-prs --> ### Linked PRs * gh-131416 <!-- /gh-linked-prs -->
3e2cceaa871a742a66711519d8e6998b186ae263
4cc82ffa377db5073fdc6f85c6f35f9c47397796
python/cpython
python__cpython-131220
# `FileTestCase` in `test_lzma` can be improved There are several tests that do not assert anything: https://github.com/python/cpython/blob/96492785b202a92af1b71f8c011ea839ca3ebb07/Lib/test/test_lzma.py#L539-L547 https://github.com/python/cpython/blob/96492785b202a92af1b71f8c011ea839ca3ebb07/Lib/test/test_lzma.py#L574-L594 I propose to assert the context manager type and the mode. I have a PR ready. <!-- gh-linked-prs --> ### Linked PRs * gh-131220 * gh-131231 * gh-131237 <!-- /gh-linked-prs -->
f6c24a5c89a1f08d583ab7f4d5c6751223f8e280
6b932edc5216d9766e70fef300a6b842ab33204c
python/cpython
python__cpython-131221
# `difflib`-generated HTML file does not use monospaced font # Bug report ### Bug description: `difflib.HtmlDiff.make_file` writes an HTML file with a CSS rule specifying Courier as the font to use. On systems which don't have it installed, browsers may fall back to the system default font, which likely won't be monospaced. ```python import difflib import webbrowser hd = difflib.HtmlDiff() html = hd.make_file(["a", "aab", "c" + "f" * 20, "eg", "ry"], ["aab", "f" * 19, "ry"]) with open("diff.html", "w") as writer: print(html, file=writer) webbrowser.open("diff.html") ``` On my system (which does not have Courier), the default font is Signika, which is what Firefox used to render the text. ![Image](https://github.com/user-attachments/assets/2ca22f2f-e111-43f1-af85-900fa7915a14) * Python 3.13.2 (main, Feb 5 2025, 08:05:21) [GCC 14.2.1 20250128] * glibc 2.41+r9+ga900dbaf70f0-1 * Arch Linux (64-bit) I _think_ is is sufficient to do: ```diff diff --git a/Lib/difflib.py b/Lib/difflib.py index bc09aa128aa..11d286a4aa8 100644 --- a/Lib/difflib.py +++ b/Lib/difflib.py @@ -1633,7 +1633,7 @@ def _line_pair_iterator(): _styles = """ :root {color-scheme: light dark} - table.diff {font-family:Courier; border:medium;} + table.diff {font-family:monospace; border:medium;} .diff_header {background-color:#e0e0e0} td.diff_header {text-align:right} .diff_next {background-color:#c0c0c0} ``` and will follow up with a pull request soon. ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131221 * gh-131242 * gh-131243 <!-- /gh-linked-prs -->
7fd61607cd28ec466717c78adfb1eb5b63add1f0
3d797e49c863c26d4d754e970ce6351465a7f50f
python/cpython
python__cpython-131197
# Improve perfomance of UUID.hex and UUID.__str__ by using bytes.hex() # Feature or enhancement ### Proposal: In my tests, using bytes.hex() speeds up calling the UUID.hex property. Additionally, using the hex property and f-strings also provides some speedup in calling uuid.UUID.__str__. ```python import uuid uuids = [uuid.uuid4() for _ in range(100000)] t1 = time.monotonic() for u in uuids: u.hex # str(u) t2 = time.monotonic() print(t2 - t1) ``` Results before and after the fix: ``` hex before: 0.021755493999989994 after: 0.01465080400066654 str before: 0.06381790500017814 after: 0.05134949700004654 ``` ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131197 <!-- /gh-linked-prs -->
1121c80fdad1fc1a175f4691f33272cf28a66e83
d7d22899e2fdfdc707f98d7297d9406de91b7e0d
python/cpython
python__cpython-132510
# Deletion of autoTSSkey during runtime finalization is not safe # Bug report The `autoTssKey` is deleted during `_PyRuntimeState_Fini` by `gilstate_tss_fini`. This isn't safe because other threads may try calling `PyGILState_Ensure()` or `PyGILState_GetThisThreadState()` concurrently during shutdown. https://github.com/python/cpython/blob/e9d210bfc248f33cc713a6026b6cbb87fdab3973/Python/pystate.c#L486-L501 We can: 1) Convert `autoTssKey` to a `_Py_thread_local` like `_Py_tss_tstate`, which doesn't require deletion 2) Don't delete `autoTssKey` at runtime finalization My preference is for the first option. cc @ZeroIntensity @ericsnowcurrently @gpshead <!-- gh-linked-prs --> ### Linked PRs * gh-132510 <!-- /gh-linked-prs -->
b8998fe2d8249565bf30ce6075ed678e1643f2a4
dcfc91e4e552e74a43f5fdf049af7a8fe7a784ee
python/cpython
python__cpython-132620
# `take_ownership` may erroneously clear MemoryError exceptions # Bug report ### Bug description: `take_ownership` clears any MemoryError exceptions when getting the previous frame fails (even if they were not raised by the call to _PyFrame_GetFrameObject): https://github.com/python/cpython/blob/1e4a4344af4f5fdc7157b195c7d333d088540035/Python/frame.c#L74-L79 I think we should save and restore the exception around the call to `_PyFrame_GetFrameObject(prev)`. Something like: ```c PyObject *exc = PyErr_GetRaisedException(); PyFrameObject *back = _PyFrame_GetFrameObject(prev); if (back == NULL) { /* Memory error here. */ assert(PyErr_ExceptionMatches(PyExc_MemoryError)); /* Nothing we can do about it */ PyErr_Clear(); } else { f->f_back = (PyFrameObject *)Py_NewRef(back); } PyErr_SetRaisedException(exc); ``` ### CPython versions tested on: 3.14, CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-132620 <!-- /gh-linked-prs -->
22830103e598c63663b462c4e42b74e7a9d3bb99
1d529cbc892b824b387d672899265ed4258b2222
python/cpython
python__cpython-131177
# Duplicated section in `InternalDocs/frames.md` In the `InternalDocs`, specifically in the "**frames.md**" file, I think there is a title **duplication** for "Generators and Coroutines," and I think the first title should be related to "**The Specials**." However, we should also review the first line of the first duplicated section. > ### Generators and Coroutines > Generators and coroutines contain a `_PyInterpreterFrame` The specials section contains the following pointers: > * Globals dict > ... https://github.com/python/cpython/blob/main/InternalDocs/frames.md <!-- gh-linked-prs --> ### Linked PRs * gh-131177 <!-- /gh-linked-prs -->
e9d210bfc248f33cc713a6026b6cbb87fdab3973
10cbd1fe88d1095a03cce24fb126d479668a67c3
python/cpython
python__cpython-131149
# Remove unused imports - March 2025 Edition # Feature or enhancement ### Proposal: There are a bunch of unused imports in Python stdlib. I'm working on pull requests to remove them. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131149 * gh-131153 * gh-131154 * gh-131155 * gh-131156 * gh-131169 <!-- /gh-linked-prs -->
14aed5e8abb84018cf48ebd1dd2ccc483013a005
7ffe93faf1db3b90968af1b1d811f39529603780
python/cpython
python__cpython-131142
# Data race between _PyMonitoring_RegisterCallback and _Py_call_instrumentation_2args in instrumentation.c # Bug report ### Bug description: I built cpython 3.13 from source with TSAN and running the following code: ```python import sys import concurrent.futures import threading if __name__ == "__main__": num_workers = 20 num_runs = 100 barrier = threading.Barrier(num_workers) tool_id = 3 event_id = sys.monitoring.events.CALL sys.monitoring.use_tool_id(tool_id, "test_tool_1") sys.monitoring.set_events(tool_id, event_id) def closure(): barrier.wait() def my_callback(code, instruction_offset, callable, arg0): pass sys.monitoring.register_callback(tool_id, event_id, my_callback) def example_function(): a = 1 b = 2 c = a + b for _ in range(num_runs): example_function() with concurrent.futures.ThreadPoolExecutor(max_workers=num_workers) as executor: futures = [] for i in range(num_workers): futures.append(executor.submit(closure)) assert len(list(f.result() for f in futures)) == num_workers ``` TSAN reports the following data race: https://gist.github.com/vfdev-5/e80f9b4528993eb1543e45a9216350e3#file-repro-log cpython version: ``` Python 3.13.2+ experimental free-threading build (heads/3.13:9e0fce413a9, Mar 12 2025, 00:48:15) [Clang 18.1.3 (1ubuntu1)] ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131142 * gh-131166 <!-- /gh-linked-prs -->
ea57ffa02e42dc430f2cb2312cdfc3d7ff7a5c70
25f24b01e3b675c6afbb653f07034a3c9a6aee32
python/cpython
python__cpython-131128
# Minimal build support when using LibreSSL # Bug report ### Bug description: On systems using LibreSSL, using OpenBSD 7.6 in this example, you see the following: ```shell $ ./configure $ gmake [...] cc -pthread -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -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 -fPIC -c ./Modules/_ssl.c -o Modules/_ssl.o ./Modules/_ssl.c:4800:18: error: call to undeclared function 'X509_OBJECT_set1_X509'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] ok = X509_OBJECT_set1_X509(ret, X509_OBJECT_get0_X509(obj)); ^ ./Modules/_ssl.c:4800:18: note: did you mean 'X509_OBJECT_get0_X509'? /usr/include/openssl/x509_vfy.h:285:7: note: 'X509_OBJECT_get0_X509' declared here X509 *X509_OBJECT_get0_X509(const X509_OBJECT *xo); ^ ./Modules/_ssl.c:4804:18: error: call to undeclared function 'X509_OBJECT_set1_X509_CRL'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] ok = X509_OBJECT_set1_X509_CRL( ^ ./Modules/_ssl.c:4804:18: note: did you mean 'X509_OBJECT_get0_X509_CRL'? /usr/include/openssl/x509_vfy.h:286:11: note: 'X509_OBJECT_get0_X509_CRL' declared here X509_CRL *X509_OBJECT_get0_X509_CRL(X509_OBJECT *xo); ^ ./Modules/_ssl.c:4821:1: error: static declaration of 'X509_STORE_get1_objects' follows non-static declaration X509_STORE_get1_objects(X509_STORE *store) ^ /usr/include/openssl/x509_vfy.h:296:24: note: previous declaration is here STACK_OF(X509_OBJECT) *X509_STORE_get1_objects(X509_STORE *xs); ^ ./Modules/_ssl.c:4824:10: error: call to undeclared function 'X509_STORE_lock'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] if (!X509_STORE_lock(store)) { ^ ./Modules/_ssl.c:4827:11: error: call to undeclared function 'sk_X509_OBJECT_deep_copy'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] ret = sk_X509_OBJECT_deep_copy(X509_STORE_get0_objects(store), ^ ./Modules/_ssl.c:4827:9: warning: incompatible integer to pointer conversion assigning to 'struct stack_st_X509_OBJECT *' from 'int' [-Wint-conversion] ret = sk_X509_OBJECT_deep_copy(X509_STORE_get0_objects(store), ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./Modules/_ssl.c:4829:5: error: call to undeclared function 'X509_STORE_unlock'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] X509_STORE_unlock(store); ^ 1 warning and 6 errors generated. gmake: *** [Makefile:3505: Modules/_ssl.o] Error 1 ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-131128 * gh-132392 <!-- /gh-linked-prs -->
1b49c8c71b90bfa97df5633e2bbf51d4a6e22a57
d87e7f35297d34755026173d84a38eedfbed78de
python/cpython
python__cpython-131124
# Support attribute completion in `pdb` for convenience variables # Feature or enhancement ### Proposal: We have completion for convenience variables, but not their attributes. `$_fra\t` gives us `$_frame`, but `$_frame.f_line\t` does not give us `$_frame.f_lineno`. We should support attributes just like other variables. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131124 <!-- /gh-linked-prs -->
b52866953a64c5e0fe57784fbcfc6bec87861563
17d06aeb5476099bc1acd89cd6f69e239e0f9350
python/cpython
python__cpython-131122
# `_Py_atomic_store_char_relaxed` uses wrong memory ordering # Bug report https://github.com/python/cpython/blob/ebc24d54bcf554403e9bf4b590d5c1f49e648e0d/Include/cpython/pyatomic_gcc.h#L520-L522 `__ATOMIC_RELEASE` should be `__ATOMIC_RELAXED`. It's not really a correctness issue because `__ATOMIC_RELEASE` is strong than `__ATOMIC_RELAXED`, but we should fix the typo. <!-- gh-linked-prs --> ### Linked PRs * gh-131122 <!-- /gh-linked-prs -->
7ffe93faf1db3b90968af1b1d811f39529603780
1fb7e2aeb7e4312b7f20f0d5f39ddd00d7762004
python/cpython
python__cpython-131118
# Update tp_finalize example to use PyErr_GetRaisedException # Documentation The [`tp_finalize`](https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_finalize ) C API doc currently uses the older [PyErr_Fetch](https://docs.python.org/3/c-api/exceptions.html#c.PyErr_Fetch) + [PyErr_Restore](https://docs.python.org/3/c-api/exceptions.html#c.PyErr_Restore) API to stash the current exception in its sample implementation. That API was deprecated in 3.12. Update the example to use the suggested replacement [PyErr_GetRaisedException](https://docs.python.org/3/c-api/exceptions.html#c.PyErr_GetRaisedException) and [PyErr_SetRaisedException](https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetRaisedException) <!-- gh-linked-prs --> ### Linked PRs * gh-131118 * gh-131476 <!-- /gh-linked-prs -->
a4832f6b9a62771725b159bc7cd6c49fb45e3bc8
5c44d7d99c470b4270b2f0e4841cf5a7f2499e15
python/cpython
python__cpython-131115
# Possibly data race in dict popitem vs do_lookup, dictobject.c # Bug report ### Bug description: I built cpython 3.13 from source with TSAN and running the following code: ```python import concurrent.futures import threading if __name__ == "__main__": num_workers = 20 num_runs = 100 barrier = threading.Barrier(num_workers) shared_dict = {} for i in range(50): shared_dict[f"{i}"] = i def closure(): barrier.wait() for _ in range(num_runs): for i in range(10): key = f"{i}" if key in shared_dict: obj = shared_dict[key] if len(shared_dict) > 0: another_obj = shared_dict.popitem() with concurrent.futures.ThreadPoolExecutor(max_workers=num_workers) as executor: futures = [] for i in range(num_workers): futures.append(executor.submit(closure)) assert len(list(f.result() for f in futures)) == num_workers ``` TSAN reports the following data race: <details> <summary> data race report </summary> ``` ================== WARNING: ThreadSanitizer: data race (pid=379167) Write of size 8 at 0x7fffb46b66b0 by thread T20: #0 __tsan_memset <null> (python3.13+0xda21d) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #1 dict_popitem_impl /project/cpython/Objects/dictobject.c:4469:25 (python3.13+0x2768db) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #2 dict_popitem /project/cpython/Objects/clinic/dictobject.c.h:220:20 (python3.13+0x2768db) #3 method_vectorcall_NOARGS /project/cpython/Objects/descrobject.c:447:24 (python3.13+0x200b61) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #4 _PyObject_VectorcallTstate /project/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x1eafea) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #5 PyObject_Vectorcall /project/cpython/Objects/call.c:327:12 (python3.13+0x1eafea) #6 _PyEval_EvalFrameDefault /project/cpython/Python/generated_cases.c.h:813:23 (python3.13+0x3e35db) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #7 _PyEval_EvalFrame /project/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3df70a) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #8 _PyEval_Vector /project/cpython/Python/ceval.c:1813:12 (python3.13+0x3df70a) #9 _PyFunction_Vectorcall /project/cpython/Objects/call.c (python3.13+0x1eb65f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #10 _PyObject_VectorcallTstate /project/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x1ef62f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #11 method_vectorcall /project/cpython/Objects/classobject.c:70:20 (python3.13+0x1ef62f) #12 _PyVectorcall_Call /project/cpython/Objects/call.c:273:16 (python3.13+0x1eb2d3) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #13 _PyObject_Call /project/cpython/Objects/call.c:348:16 (python3.13+0x1eb2d3) #14 PyObject_Call /project/cpython/Objects/call.c:373:12 (python3.13+0x1eb355) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #15 thread_run /project/cpython/./Modules/_threadmodule.c:337:21 (python3.13+0x567ef2) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #16 pythread_wrapper /project/cpython/Python/thread_pthread.h:243:5 (python3.13+0x4c0e67) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) Previous atomic read of size 8 at 0x7fffb46b66b0 by thread T3: #0 _Py_atomic_load_ptr_relaxed /project/cpython/./Include/cpython/pyatomic_gcc.h:359:18 (python3.13+0x25f09c) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #1 compare_unicode_unicode_threadsafe /project/cpython/Objects/dictobject.c:1397:26 (python3.13+0x25f09c) #2 do_lookup /project/cpython/Objects/dictobject.c:1066:23 (python3.13+0x25f09c) #3 unicodekeys_lookup_unicode_threadsafe /project/cpython/Objects/dictobject.c:1423:12 (python3.13+0x25f09c) #4 _Py_dict_lookup_threadsafe /project/cpython/Objects/dictobject.c:1478:18 (python3.13+0x260c37) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #5 _PyDict_Contains_KnownHash /project/cpython/Objects/dictobject.c:4691:10 (python3.13+0x26b366) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #6 PyDict_Contains /project/cpython/Objects/dictobject.c:4667:12 (python3.13+0x26b366) #7 PySequence_Contains /project/cpython/Objects/abstract.c:2277:19 (python3.13+0x1c2cdd) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #8 _PyEval_EvalFrameDefault /project/cpython/Python/generated_cases.c.h:2358:27 (python3.13+0x3e99c9) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #9 _PyEval_EvalFrame /project/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3df70a) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #10 _PyEval_Vector /project/cpython/Python/ceval.c:1813:12 (python3.13+0x3df70a) #11 _PyFunction_Vectorcall /project/cpython/Objects/call.c (python3.13+0x1eb65f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #12 _PyObject_VectorcallTstate /project/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x1ef62f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #13 method_vectorcall /project/cpython/Objects/classobject.c:70:20 (python3.13+0x1ef62f) #14 _PyVectorcall_Call /project/cpython/Objects/call.c:273:16 (python3.13+0x1eb2d3) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #15 _PyObject_Call /project/cpython/Objects/call.c:348:16 (python3.13+0x1eb2d3) #16 PyObject_Call /project/cpython/Objects/call.c:373:12 (python3.13+0x1eb355) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #17 thread_run /project/cpython/./Modules/_threadmodule.c:337:21 (python3.13+0x567ef2) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #18 pythread_wrapper /project/cpython/Python/thread_pthread.h:243:5 (python3.13+0x4c0e67) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) Thread T20 (tid=379188, running) created by main thread at: #0 pthread_create <null> (python3.13+0xde1df) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #1 do_start_joinable_thread /project/cpython/Python/thread_pthread.h:290:14 (python3.13+0x4bfd18) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #2 PyThread_start_joinable_thread /project/cpython/Python/thread_pthread.h:314:9 (python3.13+0x4bfb3a) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #3 ThreadHandle_start /project/cpython/./Modules/_threadmodule.c:422:9 (python3.13+0x567a87) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #4 do_start_new_thread /project/cpython/./Modules/_threadmodule.c:1849:9 (python3.13+0x567a87) #5 thread_PyThread_start_joinable_thread /project/cpython/./Modules/_threadmodule.c:1972:14 (python3.13+0x566b81) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #6 cfunction_call /project/cpython/Objects/methodobject.c:540:18 (python3.13+0x28afe7) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #7 _PyObject_MakeTpCall /project/cpython/Objects/call.c:242:18 (python3.13+0x1ea44c) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #8 _PyObject_VectorcallTstate /project/cpython/./Include/internal/pycore_call.h:166:16 (python3.13+0x1eb0a8) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #9 PyObject_Vectorcall /project/cpython/Objects/call.c:327:12 (python3.13+0x1eb0a8) #10 _PyEval_EvalFrameDefault /project/cpython/Python/generated_cases.c.h:1502:19 (python3.13+0x3e625d) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #11 _PyEval_EvalFrame /project/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3df3e2) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #12 _PyEval_Vector /project/cpython/Python/ceval.c:1813:12 (python3.13+0x3df3e2) #13 PyEval_EvalCode /project/cpython/Python/ceval.c:603:21 (python3.13+0x3df3e2) #14 run_eval_code_obj /project/cpython/Python/pythonrun.c:1381:9 (python3.13+0x4a2d0e) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #15 run_mod /project/cpython/Python/pythonrun.c:1466:19 (python3.13+0x4a2435) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #16 pyrun_file /project/cpython/Python/pythonrun.c:1295:15 (python3.13+0x49df45) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #17 _PyRun_SimpleFileObject /project/cpython/Python/pythonrun.c:517:13 (python3.13+0x49df45) #18 _PyRun_AnyFileObject /project/cpython/Python/pythonrun.c:77:15 (python3.13+0x49d698) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #19 pymain_run_file_obj /project/cpython/Modules/main.c:410:15 (python3.13+0x4db15f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #20 pymain_run_file /project/cpython/Modules/main.c:429:15 (python3.13+0x4db15f) #21 pymain_run_python /project/cpython/Modules/main.c:697:21 (python3.13+0x4da3ac) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #22 Py_RunMain /project/cpython/Modules/main.c:776:5 (python3.13+0x4da3ac) #23 pymain_main /project/cpython/Modules/main.c:806:12 (python3.13+0x4da7e8) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #24 Py_BytesMain /project/cpython/Modules/main.c:830:12 (python3.13+0x4da86b) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #25 main /project/cpython/./Programs/python.c:15:12 (python3.13+0x15c7eb) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) Thread T3 (tid=379171, running) created by main thread at: #0 pthread_create <null> (python3.13+0xde1df) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #1 do_start_joinable_thread /project/cpython/Python/thread_pthread.h:290:14 (python3.13+0x4bfd18) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #2 PyThread_start_joinable_thread /project/cpython/Python/thread_pthread.h:314:9 (python3.13+0x4bfb3a) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #3 ThreadHandle_start /project/cpython/./Modules/_threadmodule.c:422:9 (python3.13+0x567a87) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #4 do_start_new_thread /project/cpython/./Modules/_threadmodule.c:1849:9 (python3.13+0x567a87) #5 thread_PyThread_start_joinable_thread /project/cpython/./Modules/_threadmodule.c:1972:14 (python3.13+0x566b81) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #6 cfunction_call /project/cpython/Objects/methodobject.c:540:18 (python3.13+0x28afe7) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #7 _PyObject_MakeTpCall /project/cpython/Objects/call.c:242:18 (python3.13+0x1ea44c) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #8 _PyObject_VectorcallTstate /project/cpython/./Include/internal/pycore_call.h:166:16 (python3.13+0x1eb0a8) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #9 PyObject_Vectorcall /project/cpython/Objects/call.c:327:12 (python3.13+0x1eb0a8) #10 _PyEval_EvalFrameDefault /project/cpython/Python/generated_cases.c.h:1502:19 (python3.13+0x3e625d) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #11 _PyEval_EvalFrame /project/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3df3e2) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #12 _PyEval_Vector /project/cpython/Python/ceval.c:1813:12 (python3.13+0x3df3e2) #13 PyEval_EvalCode /project/cpython/Python/ceval.c:603:21 (python3.13+0x3df3e2) #14 run_eval_code_obj /project/cpython/Python/pythonrun.c:1381:9 (python3.13+0x4a2d0e) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #15 run_mod /project/cpython/Python/pythonrun.c:1466:19 (python3.13+0x4a2435) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #16 pyrun_file /project/cpython/Python/pythonrun.c:1295:15 (python3.13+0x49df45) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #17 _PyRun_SimpleFileObject /project/cpython/Python/pythonrun.c:517:13 (python3.13+0x49df45) #18 _PyRun_AnyFileObject /project/cpython/Python/pythonrun.c:77:15 (python3.13+0x49d698) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #19 pymain_run_file_obj /project/cpython/Modules/main.c:410:15 (python3.13+0x4db15f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #20 pymain_run_file /project/cpython/Modules/main.c:429:15 (python3.13+0x4db15f) #21 pymain_run_python /project/cpython/Modules/main.c:697:21 (python3.13+0x4da3ac) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #22 Py_RunMain /project/cpython/Modules/main.c:776:5 (python3.13+0x4da3ac) #23 pymain_main /project/cpython/Modules/main.c:806:12 (python3.13+0x4da7e8) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #24 Py_BytesMain /project/cpython/Modules/main.c:830:12 (python3.13+0x4da86b) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #25 main /project/cpython/./Programs/python.c:15:12 (python3.13+0x15c7eb) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) SUMMARY: ThreadSanitizer: data race (/tmp/output-python/bin/python3.13+0xda21d) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) in __tsan_memset ================== ================== WARNING: ThreadSanitizer: data race (pid=379167) Write of size 8 at 0x7fffb46b66a0 by thread T4: #0 __tsan_memset <null> (python3.13+0xda21d) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #1 dict_popitem_impl /project/cpython/Objects/dictobject.c:4469:25 (python3.13+0x2768db) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #2 dict_popitem /project/cpython/Objects/clinic/dictobject.c.h:220:20 (python3.13+0x2768db) #3 method_vectorcall_NOARGS /project/cpython/Objects/descrobject.c:447:24 (python3.13+0x200b61) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #4 _PyObject_VectorcallTstate /project/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x1eafea) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #5 PyObject_Vectorcall /project/cpython/Objects/call.c:327:12 (python3.13+0x1eafea) #6 _PyEval_EvalFrameDefault /project/cpython/Python/generated_cases.c.h:813:23 (python3.13+0x3e35db) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #7 _PyEval_EvalFrame /project/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3df70a) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #8 _PyEval_Vector /project/cpython/Python/ceval.c:1813:12 (python3.13+0x3df70a) #9 _PyFunction_Vectorcall /project/cpython/Objects/call.c (python3.13+0x1eb65f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #10 _PyObject_VectorcallTstate /project/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x1ef62f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #11 method_vectorcall /project/cpython/Objects/classobject.c:70:20 (python3.13+0x1ef62f) #12 _PyVectorcall_Call /project/cpython/Objects/call.c:273:16 (python3.13+0x1eb2d3) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #13 _PyObject_Call /project/cpython/Objects/call.c:348:16 (python3.13+0x1eb2d3) #14 PyObject_Call /project/cpython/Objects/call.c:373:12 (python3.13+0x1eb355) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #15 thread_run /project/cpython/./Modules/_threadmodule.c:337:21 (python3.13+0x567ef2) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #16 pythread_wrapper /project/cpython/Python/thread_pthread.h:243:5 (python3.13+0x4c0e67) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) Previous atomic read of size 8 at 0x7fffb46b66a0 by thread T1: #0 _Py_atomic_load_ptr_relaxed /project/cpython/./Include/cpython/pyatomic_gcc.h:359:18 (python3.13+0x25f09c) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #1 compare_unicode_unicode_threadsafe /project/cpython/Objects/dictobject.c:1397:26 (python3.13+0x25f09c) #2 do_lookup /project/cpython/Objects/dictobject.c:1066:23 (python3.13+0x25f09c) #3 unicodekeys_lookup_unicode_threadsafe /project/cpython/Objects/dictobject.c:1423:12 (python3.13+0x25f09c) #4 _Py_dict_lookup_threadsafe /project/cpython/Objects/dictobject.c:1478:18 (python3.13+0x260c37) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #5 dict_subscript /project/cpython/Objects/dictobject.c:3311:10 (python3.13+0x275be6) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #6 PyObject_GetItem /project/cpython/Objects/abstract.c:158:26 (python3.13+0x1b8e3c) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #7 _PyEval_EvalFrameDefault /project/cpython/Python/generated_cases.c.h:446:23 (python3.13+0x3e1cdf) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #8 _PyEval_EvalFrame /project/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3df70a) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #9 _PyEval_Vector /project/cpython/Python/ceval.c:1813:12 (python3.13+0x3df70a) #10 _PyFunction_Vectorcall /project/cpython/Objects/call.c (python3.13+0x1eb65f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #11 _PyObject_VectorcallTstate /project/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x1ef62f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #12 method_vectorcall /project/cpython/Objects/classobject.c:70:20 (python3.13+0x1ef62f) #13 _PyVectorcall_Call /project/cpython/Objects/call.c:273:16 (python3.13+0x1eb2d3) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #14 _PyObject_Call /project/cpython/Objects/call.c:348:16 (python3.13+0x1eb2d3) #15 PyObject_Call /project/cpython/Objects/call.c:373:12 (python3.13+0x1eb355) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #16 thread_run /project/cpython/./Modules/_threadmodule.c:337:21 (python3.13+0x567ef2) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #17 pythread_wrapper /project/cpython/Python/thread_pthread.h:243:5 (python3.13+0x4c0e67) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) Thread T4 (tid=379172, running) created by main thread at: #0 pthread_create <null> (python3.13+0xde1df) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #1 do_start_joinable_thread /project/cpython/Python/thread_pthread.h:290:14 (python3.13+0x4bfd18) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #2 PyThread_start_joinable_thread /project/cpython/Python/thread_pthread.h:314:9 (python3.13+0x4bfb3a) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #3 ThreadHandle_start /project/cpython/./Modules/_threadmodule.c:422:9 (python3.13+0x567a87) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #4 do_start_new_thread /project/cpython/./Modules/_threadmodule.c:1849:9 (python3.13+0x567a87) #5 thread_PyThread_start_joinable_thread /project/cpython/./Modules/_threadmodule.c:1972:14 (python3.13+0x566b81) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #6 cfunction_call /project/cpython/Objects/methodobject.c:540:18 (python3.13+0x28afe7) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #7 _PyObject_MakeTpCall /project/cpython/Objects/call.c:242:18 (python3.13+0x1ea44c) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #8 _PyObject_VectorcallTstate /project/cpython/./Include/internal/pycore_call.h:166:16 (python3.13+0x1eb0a8) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #9 PyObject_Vectorcall /project/cpython/Objects/call.c:327:12 (python3.13+0x1eb0a8) #10 _PyEval_EvalFrameDefault /project/cpython/Python/generated_cases.c.h:1502:19 (python3.13+0x3e625d) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #11 _PyEval_EvalFrame /project/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3df3e2) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #12 _PyEval_Vector /project/cpython/Python/ceval.c:1813:12 (python3.13+0x3df3e2) #13 PyEval_EvalCode /project/cpython/Python/ceval.c:603:21 (python3.13+0x3df3e2) #14 run_eval_code_obj /project/cpython/Python/pythonrun.c:1381:9 (python3.13+0x4a2d0e) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #15 run_mod /project/cpython/Python/pythonrun.c:1466:19 (python3.13+0x4a2435) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #16 pyrun_file /project/cpython/Python/pythonrun.c:1295:15 (python3.13+0x49df45) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #17 _PyRun_SimpleFileObject /project/cpython/Python/pythonrun.c:517:13 (python3.13+0x49df45) #18 _PyRun_AnyFileObject /project/cpython/Python/pythonrun.c:77:15 (python3.13+0x49d698) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #19 pymain_run_file_obj /project/cpython/Modules/main.c:410:15 (python3.13+0x4db15f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #20 pymain_run_file /project/cpython/Modules/main.c:429:15 (python3.13+0x4db15f) #21 pymain_run_python /project/cpython/Modules/main.c:697:21 (python3.13+0x4da3ac) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #22 Py_RunMain /project/cpython/Modules/main.c:776:5 (python3.13+0x4da3ac) #23 pymain_main /project/cpython/Modules/main.c:806:12 (python3.13+0x4da7e8) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #24 Py_BytesMain /project/cpython/Modules/main.c:830:12 (python3.13+0x4da86b) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #25 main /project/cpython/./Programs/python.c:15:12 (python3.13+0x15c7eb) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) Thread T1 (tid=379169, running) created by main thread at: #0 pthread_create <null> (python3.13+0xde1df) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #1 do_start_joinable_thread /project/cpython/Python/thread_pthread.h:290:14 (python3.13+0x4bfd18) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #2 PyThread_start_joinable_thread /project/cpython/Python/thread_pthread.h:314:9 (python3.13+0x4bfb3a) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #3 ThreadHandle_start /project/cpython/./Modules/_threadmodule.c:422:9 (python3.13+0x567a87) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #4 do_start_new_thread /project/cpython/./Modules/_threadmodule.c:1849:9 (python3.13+0x567a87) #5 thread_PyThread_start_joinable_thread /project/cpython/./Modules/_threadmodule.c:1972:14 (python3.13+0x566b81) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #6 cfunction_call /project/cpython/Objects/methodobject.c:540:18 (python3.13+0x28afe7) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #7 _PyObject_MakeTpCall /project/cpython/Objects/call.c:242:18 (python3.13+0x1ea44c) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #8 _PyObject_VectorcallTstate /project/cpython/./Include/internal/pycore_call.h:166:16 (python3.13+0x1eb0a8) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #9 PyObject_Vectorcall /project/cpython/Objects/call.c:327:12 (python3.13+0x1eb0a8) #10 _PyEval_EvalFrameDefault /project/cpython/Python/generated_cases.c.h:1502:19 (python3.13+0x3e625d) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #11 _PyEval_EvalFrame /project/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3df3e2) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #12 _PyEval_Vector /project/cpython/Python/ceval.c:1813:12 (python3.13+0x3df3e2) #13 PyEval_EvalCode /project/cpython/Python/ceval.c:603:21 (python3.13+0x3df3e2) #14 run_eval_code_obj /project/cpython/Python/pythonrun.c:1381:9 (python3.13+0x4a2d0e) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #15 run_mod /project/cpython/Python/pythonrun.c:1466:19 (python3.13+0x4a2435) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #16 pyrun_file /project/cpython/Python/pythonrun.c:1295:15 (python3.13+0x49df45) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #17 _PyRun_SimpleFileObject /project/cpython/Python/pythonrun.c:517:13 (python3.13+0x49df45) #18 _PyRun_AnyFileObject /project/cpython/Python/pythonrun.c:77:15 (python3.13+0x49d698) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #19 pymain_run_file_obj /project/cpython/Modules/main.c:410:15 (python3.13+0x4db15f) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #20 pymain_run_file /project/cpython/Modules/main.c:429:15 (python3.13+0x4db15f) #21 pymain_run_python /project/cpython/Modules/main.c:697:21 (python3.13+0x4da3ac) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #22 Py_RunMain /project/cpython/Modules/main.c:776:5 (python3.13+0x4da3ac) #23 pymain_main /project/cpython/Modules/main.c:806:12 (python3.13+0x4da7e8) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #24 Py_BytesMain /project/cpython/Modules/main.c:830:12 (python3.13+0x4da86b) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) #25 main /project/cpython/./Programs/python.c:15:12 (python3.13+0x15c7eb) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) SUMMARY: ThreadSanitizer: data race (/tmp/output-python/bin/python3.13+0xda21d) (BuildId: 3ae84a424a863e898f8ae5899a1f37386e6a2faa) in __tsan_memset ================== Traceback (most recent call last): File "/project/playground/cpython_checks/dict_popitem/repro.py", line 31, in <module> assert len(list(f.result() for f in futures)) == num_workers ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/project/playground/cpython_checks/dict_popitem/repro.py", line 31, in <genexpr> assert len(list(f.result() for f in futures)) == num_workers ~~~~~~~~^^ File "/tmp/output-python/lib/python3.13t/concurrent/futures/_base.py", line 456, in result return self.__get_result() ~~~~~~~~~~~~~~~~~^^ File "/tmp/output-python/lib/python3.13t/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/tmp/output-python/lib/python3.13t/concurrent/futures/thread.py", line 59, in run result = self.fn(*self.args, **self.kwargs) File "/project/playground/cpython_checks/dict_popitem/repro.py", line 23, in closure obj = shared_dict[key] ~~~~~~~~~~~^^^^^ KeyError: '0' ThreadSanitizer: reported 2 warnings ``` </details> We believe that this should be a bug. An expected behaviour should be no race in c-level. cpython version: ``` Python 3.13.2+ experimental free-threading build (heads/3.13:aa2c4e4417d, Mar 5 2025, 16:21:25) [Clang 18.1.3 (1ubuntu1)] ``` cc @hawkinsp ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131115 * gh-131119 <!-- /gh-linked-prs -->
c00ac578241b3213ceb79c1f32bc83ea471f02da
ad90c5fabc415d4e46205947cceda82893ec1460
python/cpython
python__cpython-131044
# Guards for WIN32_LEAN_AND_MEAN missing in some places # Bug report ### Bug description: Macro guards for the `WIN32_LEAN_AND_MEAN` macro are missing in some places. This leads to redefinition warnings on the xbox that define this as part of it's toolchain. ### CPython versions tested on: 3.13 ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-131044 * gh-131084 * gh-131085 <!-- /gh-linked-prs -->
de8818ae233b8e7722aa5d6f91d4b5a04bd039df
425e0af74fb882b95f81923123bd4afad0cda157
python/cpython
python__cpython-131051
# Allow CPython test to handle TLS libraries lacking FFDHE ciphersuites # Feature or enhancement ### Proposal: Some cryptography TLS libraries, such as [AWS-LC](https://github.com/search?q=repo%3Aaws%2Faws-lc+path%3Assl%2F+%28%28%22DHE%22+OR+%22dhe%22%29+AND+NOT+%28%22ECDHE%22+OR+%22ecdhe%22%29%29&type=code) and [BoringSSL](https://github.com/search?q=repo%3Agoogle%2Fboringssl+path%3Assl%2F+%28%28%22DHE%22+OR+%22dhe%22%29+AND+NOT+%28%22ECDHE%22+OR+%22ecdhe%22%29%29&type=code), lack support for "finite field" ephemeral Diffie-Hellman (FFDHE) TLS ciphersuites. This causes failure `test_ssl.ThreadedTests.test_dh_params` when CPython is build against such libraries, as that test case assumes ciphersuite support of FFDHE. This issue proposes modifying `test_dh_params` to skip itself if the underlying TLS library does not support FFDHE. ### 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-131051 * gh-131874 * gh-131875 <!-- /gh-linked-prs -->
be2d2181e62cd138b0cdf80ebc0dd4058187c52a
a5949986d631391d37b1b329ad8badcf2000f9a9
python/cpython
python__cpython-131053
# `enum.Flag.__contains__` changed behavior since python 3.12 # Bug report ### Bug description: I noticed some strange behavior with `enum.Flag` an the `__contains__` method in Python 3.12/3.13, as shown in the following examples. **Problem 1: Behavior changes at runtime** In the following code snippet the first print statement returns `False`, which is expected, since `3` is not a member of `Weekday`. However, the second print statement returns `True`, which is unexpected, since `3` is still not a member of `Weekday`. ```python import enum class Weekday(enum.Flag): MONDAY = 1 TUESDAY = 2 WEDNESDAY = 4 THURSDAY = 8 FRIDAY = 16 SATURDAY = 32 SUNDAY = 64 print(f"{3 in Weekday}") # => False (expected) _ = Weekday.MONDAY | Weekday.TUESDAY print(f"{3 in Weekday}") # => True (not expected) ``` **Problem 2: Behavior is not comparable to Python 3.11** Since Python 3.12 the behavior of `Enum.__contains__` has changed, so that it is possible to compare not only with an enum-member, but also with non-enum-members (see [here](https://github.com/python/cpython/pull/93298) or [here](https://docs.python.org/3/library/enum.html#enum.EnumType.__contains__)). So with Python 3.11 the code above will raise an `TypeError: unsupported operand type(s) for 'in': 'int' and 'EnumType'`. There you have to change the code to the following. But this in turn always produces unexpected behavior in Python 3.12/3.13. ```python import enum class Weekday(enum.Flag): MONDAY = 1 TUESDAY = 2 WEDNESDAY = 4 THURSDAY = 8 FRIDAY = 16 SATURDAY = 32 SUNDAY = 64 print(f"{Weekday(3) in Weekday}") # => Python 3.11: False (expected) Python 3.12/3.13: True (not expected) _ = Weekday.MONDAY | Weekday.TUESDAY print(f"{Weekday(3) in Weekday}") # => Python 3.11: False (expected) Python 3.12/3.13: True (not expected) ``` **Conclusion** I would have expected that in all cases the result is `False`, but since Python 3.12 it gets very strange... ### CPython versions tested on: 3.12, 3.13 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-131053 * gh-131167 * gh-131232 <!-- /gh-linked-prs -->
17d06aeb5476099bc1acd89cd6f69e239e0f9350
db6a998b18e9476226507144b3b2fab854095dbc
python/cpython
python__cpython-131036
# use -flto=thin for clang-cl on Windows This started off as a build time analysis (https://github.com/python/cpython/issues/130090#issuecomment-2709951815), but since I now have the infrastructure, I tried `-flto=thin`, too: - faster in building 520.6 vs 651.2 seconds - is neutral on the pyperformance benchmarks - would bring us in sync with Linux, because there `CONFIGURE_CFLAGS_NODIST` and `CONFIGURE_LDFLAGS_NOLTO` both use `-flto=thin` when I configure for clang in WSL Ubuntu-24.04. See also the discussion why not to use full `-flto` in https://github.com/python/cpython/issues/130048 | Benchmark | clang.pgo.20.1.0-rc2 | clang.pgo.thin.20.1.0-rc2 | |---------------------------------|:--------------------:|:-------------------------:| | Geometric mean | (ref) | 1.00x faster | <details><summary>Detailed pybenchmark results</summary> <p> | Benchmark | clang.pgo.20.1.0-rc2 | clang.pgo.thin.20.1.0-rc2 | |---------------------------------|:--------------------:|:-------------------------:| | float | 95.0 ms | 89.7 ms: 1.06x faster | | json_loads | 29.8 us | 28.6 us: 1.04x faster | | mdp | 2.86 sec | 2.77 sec: 1.03x faster | | html5lib | 68.3 ms | 66.2 ms: 1.03x faster | | async_tree_none_tg | 330 ms | 320 ms: 1.03x faster | | pyflate | 518 ms | 505 ms: 1.03x faster | | sqlite_synth | 3.21 us | 3.13 us: 1.03x faster | | pidigits | 228 ms | 223 ms: 1.02x faster | | bench_mp_pool | 168 ms | 165 ms: 1.02x faster | | async_tree_eager_io | 742 ms | 727 ms: 1.02x faster | | generators | 34.5 ms | 33.8 ms: 1.02x faster | | comprehensions | 18.3 us | 17.9 us: 1.02x faster | | async_tree_cpu_io_mixed | 641 ms | 629 ms: 1.02x faster | | scimark_sparse_mat_mult | 4.51 ms | 4.43 ms: 1.02x faster | | async_tree_memoization | 425 ms | 417 ms: 1.02x faster | | sympy_expand | 538 ms | 529 ms: 1.02x faster | | unpack_sequence | 57.0 ns | 56.0 ns: 1.02x faster | | regex_dna | 209 ms | 205 ms: 1.02x faster | | async_generators | 465 ms | 458 ms: 1.02x faster | | scimark_sor | 140 ms | 137 ms: 1.02x faster | | sympy_str | 319 ms | 314 ms: 1.02x faster | | async_tree_io_tg | 751 ms | 740 ms: 1.01x faster | | regex_effbot | 3.14 ms | 3.10 ms: 1.01x faster | | async_tree_eager_tg | 272 ms | 268 ms: 1.01x faster | | pickle_dict | 27.3 us | 27.0 us: 1.01x faster | | async_tree_eager_memoization_tg | 363 ms | 359 ms: 1.01x faster | | sympy_integrate | 22.5 ms | 22.2 ms: 1.01x faster | | sympy_sum | 181 ms | 179 ms: 1.01x faster | | 2to3 | 390 ms | 386 ms: 1.01x faster | | hexiom | 6.68 ms | 6.61 ms: 1.01x faster | | docutils | 3.03 sec | 3.00 sec: 1.01x faster | | sqlglot_normalize | 121 ms | 120 ms: 1.01x faster | | async_tree_memoization_tg | 392 ms | 389 ms: 1.01x faster | | async_tree_cpu_io_mixed_tg | 614 ms | 609 ms: 1.01x faster | | tomli_loads | 2.20 sec | 2.18 sec: 1.01x faster | | spectral_norm | 102 ms | 101 ms: 1.01x faster | | python_startup_no_site | 34.4 ms | 34.2 ms: 1.01x faster | | genshi_text | 24.6 ms | 24.5 ms: 1.01x faster | | dulwich_log | 119 ms | 118 ms: 1.00x faster | | go | 128 ms | 128 ms: 1.00x faster | | deltablue | 3.62 ms | 3.63 ms: 1.00x slower | | unpickle_pure_python | 247 us | 248 us: 1.00x slower | | xml_etree_generate | 107 ms | 107 ms: 1.01x slower | | django_template | 39.2 ms | 39.4 ms: 1.01x slower | | coroutines | 24.8 ms | 25.0 ms: 1.01x slower | | mako | 13.3 ms | 13.5 ms: 1.01x slower | | unpickle | 15.9 us | 16.1 us: 1.01x slower | | nbody | 119 ms | 121 ms: 1.01x slower | | fannkuch | 465 ms | 472 ms: 1.01x slower | | crypto_pyaes | 81.3 ms | 82.6 ms: 1.02x slower | | json_dumps | 11.5 ms | 11.7 ms: 1.02x slower | | deepcopy | 285 us | 291 us: 1.02x slower | | pprint_safe_repr | 858 ms | 876 ms: 1.02x slower | | xml_etree_iterparse | 136 ms | 139 ms: 1.02x slower | | gc_traversal | 5.03 ms | 5.14 ms: 1.02x slower | | meteor_contest | 115 ms | 117 ms: 1.02x slower | | deepcopy_memo | 33.8 us | 34.7 us: 1.03x slower | | richards_super | 51.1 ms | 52.6 ms: 1.03x slower | | scimark_fft | 327 ms | 337 ms: 1.03x slower | | richards | 44.9 ms | 46.3 ms: 1.03x slower | | pickle_list | 4.83 us | 4.99 us: 1.03x slower | | deepcopy_reduce | 2.93 us | 3.03 us: 1.03x slower | | pprint_pformat | 1.74 sec | 1.80 sec: 1.03x slower | | logging_simple | 10.9 us | 11.4 us: 1.05x slower | | logging_format | 12.1 us | 12.6 us: 1.05x slower | | xml_etree_parse | 197 ms | 208 ms: 1.05x slower | | Geometric mean | (ref) | 1.00x faster | </p> </details> | | pgo_clang_20.1.0-rc2 | pgo_clang_thin_20.1.0-rc2 | |------------|:--------------------:|:-------------------------:| | pginstr | 297.2 | 219.3 | | pgo | 70.0 | 69.0 | | kill | 1.2 | 0.5 | | pgupd | 282.8 | 231.7 | | total time | 651.2 | 520.6 | <details><summary>Details pginstrument</summary> <p> | | pgo_clang_20.1.0-rc2 | pgo_clang_thin_20.1.0-rc2 | |---------------------|:--------------------:|:-------------------------:| | _freeze_module | 38.5 | 40.0 | | python314 | 141.5 | 81.3 | | pyexpat | 52.7 | 3.9 | | _elementtree | 51.8 | 5.3 | | sqlite3 | 46.0 | 42.4 | | liblzma | 18.2 | 16.5 | | _decimal | 12.4 | 7.7 | | _testcapi | 8.3 | 7.1 | | _bz2 | 7.0 | 4.9 | | _ctypes | 6.9 | 7.5 | | _testlimitedcapi | 4.9 | 4.3 | | _wmi | 4.5 | 3.0 | | _overlapped | 4.5 | 3.2 | | _asyncio | 4.0 | 5.2 | | _lzma | 3.8 | 1.8 | | _ssl | 3.7 | 5.5 | | _ctypes_test | 3.7 | 3.4 | | _multiprocessing | 3.5 | 2.7 | | _sqlite3 | 3.4 | 2.8 | | venvwlauncher | 3.3 | 2.7 | | _zoneinfo | 3.1 | 3.4 | | unicodedata | 2.7 | 3.0 | | pyshellext | 2.7 | 2.6 | | pyw | 2.7 | 2.7 | | py | 2.6 | 2.5 | | _socket | 2.4 | 3.7 | | _testinternalcapi | 2.4 | 2.2 | | _tkinter | 2.2 | 4.1 | | _testclinic | 2.0 | 1.9 | | _hashlib | 1.8 | 3.1 | | select | 1.8 | 2.2 | | venvlauncher | 1.8 | 1.7 | | winsound | 1.7 | 3.3 | | _uuid | 1.6 | 3.2 | | _queue | 1.6 | 2.3 | | _testembed | 1.5 | 1.5 | | _testbuffer | 1.4 | 1.3 | | pythonw | 1.1 | 1.1 | | _testconsole | 1.1 | 1.1 | | _testmultiphase | 1.0 | 1.0 | | _testsinglephase | 1.0 | 1.0 | | python | 1.0 | 0.9 | | _testclinic_limited | 0.9 | 0.9 | | _testimportmultiple | 0.9 | 0.9 | | python3 | 0.5 | 0.5 | | total | 465.8 | 303.3 | </p> </details> <details><summary>Details pgupdate</summary> <p> | | pgo_clang_20.1.0-rc2 | pgo_clang_thin_20.1.0-rc2 | |---------------------|:--------------------:|:-------------------------:| | _freeze_module | 38.0 | 39.5 | | python314 | 141.9 | 95.4 | | sqlite3 | 44.4 | 42.9 | | liblzma | 17.3 | 16.5 | | _decimal | 11.2 | 8.7 | | _testcapi | 8.6 | 7.3 | | _ctypes | 8.0 | 7.2 | | _bz2 | 7.8 | 5.5 | | _ssl | 5.2 | 5.6 | | _testlimitedcapi | 5.0 | 4.2 | | pyexpat | 4.6 | 3.6 | | _asyncio | 4.5 | 4.6 | | _socket | 4.3 | 3.5 | | _tkinter | 4.0 | 4.2 | | _ctypes_test | 3.7 | 3.4 | | _overlapped | 3.5 | 3.7 | | _elementtree | 3.5 | 4.5 | | _wmi | 3.5 | 3.1 | | _zoneinfo | 3.2 | 3.2 | | _lzma | 3.2 | 1.9 | | unicodedata | 3.2 | 3.0 | | _sqlite3 | 3.1 | 2.7 | | _hashlib | 3.1 | 3.3 | | venvwlauncher | 3.1 | 3.0 | | _multiprocessing | 2.8 | 2.6 | | pyshellext | 2.7 | 2.6 | | pyw | 2.6 | 2.6 | | _uuid | 2.6 | 2.8 | | py | 2.6 | 2.7 | | _testinternalcapi | 2.4 | 2.2 | | _testclinic | 2.0 | 1.9 | | _queue | 1.9 | 2.2 | | winsound | 1.8 | 3.0 | | venvlauncher | 1.7 | 1.5 | | select | 1.6 | 2.0 | | _testembed | 1.5 | 1.4 | | _testbuffer | 1.4 | 1.3 | | _testconsole | 1.1 | 1.0 | | pythonw | 1.1 | 1.1 | | _testmultiphase | 1.0 | 1.1 | | _testsinglephase | 1.0 | 1.0 | | python | 1.0 | 0.9 | | _testclinic_limited | 0.9 | 0.9 | | _testimportmultiple | 0.9 | 0.9 | | python3 | 0.5 | 0.5 | | total | 372.9 | 316.8 | </p> </details> <!-- gh-linked-prs --> ### Linked PRs * gh-131036 <!-- /gh-linked-prs -->
91d6db7ee0006860a93d96c4c8bc58bfd8a38f6b
2bef8ea8ea045d20394f0daec7a5c5b1046a4e22
python/cpython
python__cpython-131071
# test_math.test_fma_zero_result() fails with the musl C library # Bug report ### Bug description: 1. While installing Python 3.13 version in docker:dind endingup without installation, getting the issue like as mentioned below ``` 675.0 0:00:26 load avg: 0.94 [18/44] test_fstring 675.0 /Python-3.13.2/Lib/test/test_fstring.py:1655: SyntaxWarning: invalid escape sequence '\N' 675.0 self.assertEqual(f'{b"\N{OX}"=}', 'b"\\N{OX}"=b\'\\\\N{OX}\'') 691.8 0:00:43 load avg: 0.96 [19/44] test_functools 692.5 0:00:44 load avg: 0.96 [20/44] test_generators 692.9 0:00:44 load avg: 0.96 [21/44] test_hashlib 693.7 0:00:45 load avg: 0.96 [22/44] test_heapq 694.4 0:00:46 load avg: 0.96 [23/44] test_int 695.2 0:00:47 load avg: 0.96 [24/44] test_itertools 699.8 0:00:51 load avg: 0.96 [25/44] test_json 704.2 0:00:56 load avg: 0.96 [26/44] test_long 706.7 0:00:58 load avg: 0.97 [27/44] test_lzma 706.8 0:00:58 load avg: 0.97 [28/44] test_math -- test_lzma skipped 709.6 test test_math failed 709.6 0:01:01 load avg: 0.97 [29/44] test_memoryview -- test_math failed (1 failure) 710.1 0:01:01 load avg: 0.97 [30/44] test_operator 710.3 0:01:02 load avg: 0.97 [31/44] test_ordered_dict 711.5 0:01:03 load avg: 0.97 [32/44] test_patma 711.7 0:01:03 load avg: 0.97 [33/44] test_pickle 718.3 0:01:10 load avg: 0.97 [34/44] test_pprint 718.6 0:01:10 load avg: 0.97 [35/44] test_re 719.7 test test_re failed 719.7 0:01:11 load avg: 0.98 [36/44] test_set -- test_re failed (2 failures) 724.7 0:01:16 load avg: 0.98 [37/44] test_sqlite3 725.6 0:01:17 load avg: 0.98 [38/44] test_statistics 733.0 0:01:24 load avg: 0.98 [39/44] test_str 735.1 0:01:26 load avg: 0.98 [40/44] test_struct 735.8 0:01:27 load avg: 0.98 [41/44] test_tabnanny 736.3 0:01:28 load avg: 0.98 [42/44] test_time 739.5 0:01:31 load avg: 0.98 [43/44] test_xml_etree 740.2 0:01:32 load avg: 0.98 [44/44] test_xml_etree_c 741.3 741.3 Total duration: 1 min 33 sec 741.3 Total tests: run=9,178 failures=3 skipped=203 741.3 Total test files: run=44/44 failed=2 skipped=2 741.3 Result: FAILURE 741.3 make: *** [Makefile:886: profile-run-stamp] Error 2 ``` 2. Which is happening in only docker:dind, when I am trying in centos, ubuntu able to install. 3. And one more with the Python 3.12.9 version able to install in in docker:dind and logs are ``` #15 578.8 0:00:21 load avg: 1.50 [18/44] test_fstring #15 578.8 /Python-3.12.9/Lib/test/test_fstring.py:1769: SyntaxWarning: invalid escape sequence '\N' #15 578.8 self.assertEqual(f'{b"\N{OX}"=}', 'b"\\N{OX}"=b\'\\\\N{OX}\'') #15 593.3 0:00:35 load avg: 1.39 [19/44] test_functools #15 593.8 0:00:36 load avg: 1.36 [20/44] test_generators #15 594.1 0:00:36 load avg: 1.36 [21/44] test_hashlib #15 594.8 0:00:37 load avg: 1.36 [22/44] test_heapq #15 595.3 0:00:37 load avg: 1.36 [23/44] test_int #15 595.7 0:00:38 load avg: 1.36 [24/44] test_itertools #15 599.2 0:00:41 load avg: 1.33 [25/44] test_json #15 629.5 0:01:11 load avg: 1.20 [26/44] test_long -- test_json passed in 30.3 sec #15 631.7 0:01:13 load avg: 1.20 [27/44] test_lzma #15 631.8 0:01:14 load avg: 1.20 [28/44] test_math -- test_lzma skipped #15 633.8 0:01:16 load avg: 1.20 [29/44] test_memoryview #15 634.4 0:01:16 load avg: 1.18 [30/44] test_operator #15 634.5 0:01:16 load avg: 1.18 [31/44] test_ordered_dict #15 635.5 0:01:17 load avg: 1.18 [32/44] test_patma #15 635.8 0:01:18 load avg: 1.18 [33/44] test_pickle #15 641.0 0:01:23 load avg: 1.17 [34/44] test_pprint #15 641.3 0:01:23 load avg: 1.17 [35/44] test_re #15 642.1 test test_re failed #15 642.1 0:01:24 load avg: 1.17 [36/44] test_set -- test_re failed (2 failures) #15 646.1 0:01:28 load avg: 1.15 [37/44] test_sqlite3 #15 646.9 0:01:29 load avg: 1.15 [38/44] test_statistics #15 648.3 0:01:30 load avg: 1.15 [39/44] test_struct #15 648.9 0:01:31 load avg: 1.22 [40/44] test_tabnanny #15 649.4 0:01:31 load avg: 1.22 [41/44] test_time #15 652.5 0:01:34 load avg: 1.22 [42/44] test_unicode #15 654.5 0:01:36 load avg: 1.20 [43/44] test_xml_etree #15 655.0 0:01:37 load avg: 1.20 [44/44] test_xml_etree_c #15 655.9 #15 655.9 Total duration: 1 min 38 sec #15 655.9 Total tests: run=8,930 failures=2 skipped=192 #15 655.9 Total test files: run=44/44 failed=1 skipped=2 #15 655.9 Result: FAILURE #15 656.0 true #15 656.0 # Remove profile generation binary since we are done with it. #15 656.0 make clean-retain-profile #15 656.1 make[1]: Entering directory '/Python-3.12.9' #15 656.1 find . -depth -name '__pycache__' -exec rm -rf {} ';' #15 656.2 find . -name '*.py[co]' -exec rm -f {} ';' #15 656.2 find . -name '*.[oa]' -exec rm -f {} ';' #15 656.5 find . -name '*.s[ol]' -exec rm -f {} ';' #15 656.6 find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';' #15 656.7 find . -name '*.lto' -exec rm -f {} ';' #15 656.7 find . -name '*.wasm' -exec rm -f {} ';' #15 656.7 find . -name '*.lst' -exec rm -f {} ';' #15 656.8 find build -name 'fficonfig.h' -exec rm -f {} ';' || true #15 656.8 find build -name '*.py' -exec rm -f {} ';' || true #15 656.8 find build -name '*.py[co]' -exec rm -f {} ';' || true #15 656.8 rm -f pybuilddir.txt #15 656.8 rm -f Lib/lib2to3/*Grammar*.pickle ``` 4. So what could be the issue ?. 5. I am using following Dockerfile code to install Python ``` # Use the official Docker DinD image as the base image ARG PYTHON_VERSION=3.13.2 FROM docker:dind # Install necessary packages and dependencies RUN apk add --no-cache \ build-base \ bzip2-dev \ ncurses-dev \ gdbm-dev \ xz-dev \ tk-dev \ util-linux-dev \ readline-dev \ zlib-dev \ openssl-dev \ libffi-dev \ wget RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \ && tar xvf Python-${PYTHON_VERSION}.tgz \ && cd Python-${PYTHON_VERSION} \ && ./configure --enable-optimizations \ && make altinstall \ && pip3.13 install --upgrade pip ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131071 * gh-131134 * gh-131179 <!-- /gh-linked-prs -->
6146295a5b8e9286ccb8f90818b764c9a0192090
4b540313238de9d53bd9d9866eb481e954ad508f
python/cpython
python__cpython-131021
# Pylauncher does not correctly detect a BOM when searching for the shebang # Bug report ### Bug description: This is due to https://github.com/python/cpython/blob/475f933ed8b1c9546f1b5497a2241140c7065b5f/PC/launcher2.c#L1080-L1081 for wich clang-cl creates the following warnings: ``` 1>..\PC\launcher2.c(1080,29): warning : result of comparison of constant 239 with expression of type 'char' is always false [-Wtautological-constant-out-of-range-compare] 1>..\PC\launcher2.c(1081,34): warning : result of comparison of constant 191 with expression of type 'char' is always false [-Wtautological-constant-out-of-range-compare] 1>..\PC\launcher2.c(1081,18): warning : result of comparison of constant 187 with expression of type 'char' is always false [-Wtautological-constant-out-of-range-compare] ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-131021 * gh-131047 * gh-131048 <!-- /gh-linked-prs -->
36ef3bfe39d767e283b55fe86f34e7671b7f5d1c
5a484714c3497dd5c67a1469c0cc246bf1452892
python/cpython
python__cpython-131881
# Add tests for errors during byte formatting as for strings # Bug report ### Bug description: There are tests for string formatting errors - https://github.com/python/cpython/blob/main/Lib/test/test_str.py#L1581-L1591, but no tests for byte formatting errors - https://github.com/python/cpython/blob/main/Lib/test/test_bytes.py#L719. I would like to send a PR to fix this. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131881 * gh-132114 * gh-132115 <!-- /gh-linked-prs -->
05557788f3c284ede73e6f94810ec796bb9d3721
06a110f5227ba9d52f6205fde55924a14cab36ff
python/cpython
python__cpython-131006
# [sqlite3] Converter Not Called with Aggregate Functions # Bug report ### Bug description: The converter functions are correctly called when using the raw field name in a query, but when you use an aggregate function like `MIN(fieldname)` the value is returned as a string. ## Minimal Example ```python import sqlite3 sqlite3.register_converter('faketype', lambda s: int(s.rstrip(b';'))) con = sqlite3.connect(':memory:', detect_types=sqlite3.PARSE_DECLTYPES) cur = con.execute('CREATE TABLE awesome(f faketype)') cur.execute('INSERT INTO awesome(f) VALUES("5;")') queries = ['SELECT f FROM awesome', 'SELECT MIN(f) FROM awesome'] for query in queries: cur.execute(query) result = cur.fetchone()[0] print(f'{query}\n{type(result)} {result}\n') ``` ## Expected Output ```console SELECT f FROM awesome <class 'int'> 5 SELECT MIN(f) FROM awesome <class 'int'> 5 ``` Both queries return an integer ## Actual Output ```console SELECT f FROM awesome <class 'int'> 5 SELECT MIN(f) FROM awesome <class 'str'> 5; ``` The query with just the fieldname `f` returns the proper type (int). The query using the aggregate function `MIN(f)` returns a string, indicating the converter function has not been called. ## Additional information A slightly expanded example is [available as gist](https://gist.github.com/DLu/19cb472d9864274931ada38c729fa686) `Python 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0] on linux` / Ubuntu 24.04 ### CPython versions tested on: 3.12 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131006 * gh-131385 * gh-131386 <!-- /gh-linked-prs -->
f48887fb97651c02c5e412a75ed8b51a4ca11e6a
149fbb01f2f49e6d87ab916d099d19c57f7ed80a
python/cpython
python__cpython-131001
# New REPL exits when there are non-string candidates for suggestions # Crash report ### What happened? The new REPL in main will exit if a suggestion would be offered, but there are non-string candidates like below: ```python >>> import runpy ... runpy._run_module_code("blech", {0: "", "bluch": ""}, "") ... Exception ignored in the internal traceback machinery: Traceback (most recent call last): File "/home/danzin/projects/cpython/Lib/traceback.py", line 139, in _print_exception_bltin return print_exception(exc, limit=BUILTIN_EXCEPTION_LIMIT, file=file, colorize=colorize) File "/home/danzin/projects/cpython/Lib/traceback.py", line 129, in print_exception te = TracebackException(type(value), value, tb, limit=limit, compact=True) File "/home/danzin/projects/cpython/Lib/traceback.py", line 1138, in __init__ context = TracebackException( File "/home/danzin/projects/cpython/Lib/traceback.py", line 1094, in __init__ suggestion = _compute_suggestion_error(exc_value, exc_traceback, wrong_name) File "/home/danzin/projects/cpython/Lib/traceback.py", line 1535, in _compute_suggestion_error return _suggestions._generate_suggestions(d, wrong_name) TypeError: all elements in 'candidates' must be strings Traceback (most recent call last): File "<python-input-0>", line 2, in <module> File "/home/danzin/projects/cpython/Lib/runpy.py", line 98, in _run_module_code _run_code(code, mod_globals, init_globals, File "/home/danzin/projects/cpython/Lib/runpy.py", line 88, in _run_code exec(code, run_globals) File "<string>", line 1, in <module> NameError: name 'blech' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/danzin/projects/cpython/Lib/_pyrepl/console.py", line 173, in _excepthook lines = traceback.format_exception( File "/home/danzin/projects/cpython/Lib/traceback.py", line 154, in format_exception te = TracebackException(type(value), value, tb, limit=limit, compact=True) File "/home/danzin/projects/cpython/Lib/traceback.py", line 1094, in __init__ suggestion = _compute_suggestion_error(exc_value, exc_traceback, wrong_name) File "/home/danzin/projects/cpython/Lib/traceback.py", line 1535, in _compute_suggestion_error return _suggestions._generate_suggestions(d, wrong_name) TypeError: all elements in 'candidates' must be strings During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/danzin/projects/cpython/Lib/runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/danzin/projects/cpython/Lib/runpy.py", line 88, in _run_code exec(code, run_globals) File "/home/danzin/projects/cpython/Lib/_pyrepl/__main__.py", line 6, in <module> __pyrepl_interactive_console() File "/home/danzin/projects/cpython/Lib/_pyrepl/main.py", line 59, in interactive_console run_multiline_interactive_console(console) File "/home/danzin/projects/cpython/Lib/_pyrepl/simple_interact.py", line 152, in run_multiline_interactive_console more = console.push(_strip_final_indent(statement), filename=input_name, _symbol="single") # type: ignore[call-arg] File "/home/danzin/projects/cpython/Lib/code.py", line 324, in push more = self.runsource(source, filename, symbol=_symbol) File "/home/danzin/projects/cpython/Lib/_pyrepl/console.py", line 231, in runsource result = self.runcode(code) File "/home/danzin/projects/cpython/Lib/_pyrepl/console.py", line 191, in runcode self.showtraceback() File "/home/danzin/projects/cpython/Lib/code.py", line 128, in showtraceback self._showtraceback(typ, value, tb.tb_next, "") File "/home/danzin/projects/cpython/Lib/code.py", line 144, in _showtraceback self._excepthook(typ, value, tb) File "/home/danzin/projects/cpython/Lib/_pyrepl/console.py", line 179, in _excepthook lines = traceback.format_exception( File "/home/danzin/projects/cpython/Lib/traceback.py", line 154, in format_exception te = TracebackException(type(value), value, tb, limit=limit, compact=True) File "/home/danzin/projects/cpython/Lib/traceback.py", line 1138, in __init__ context = TracebackException( File "/home/danzin/projects/cpython/Lib/traceback.py", line 1094, in __init__ suggestion = _compute_suggestion_error(exc_value, exc_traceback, wrong_name) File "/home/danzin/projects/cpython/Lib/traceback.py", line 1535, in _compute_suggestion_error return _suggestions._generate_suggestions(d, wrong_name) TypeError: all elements in 'candidates' must be strings ``` This is an offshoot of #129573, where code like above would abort in 3.12. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.14.0a5+ (heads/main:a3990df6121, Mar 9 2025, 00:02:58) [GCC 13.3.0] <!-- gh-linked-prs --> ### Linked PRs * gh-131001 * gh-135019 * gh-135020 * gh-135030 <!-- /gh-linked-prs -->
baccfdb3d4d004cfb5308674e5e6ea6e598abcd7
5f61cde80a9b33c8e118b1c009fe2aaa4bb87356
python/cpython
python__cpython-130962
# datetime: pure Python implementation of `fromisoformat()` handles times with trailing spaces inconsistently with the C extension # Bug report ### Bug description: Discovered primarily because PyPy uses the Python version of `datetime` from the stdlib, and `django.utils.dateparse.parse_datetime()` supports wider range of values than the C version of `datetime.datetime.fromisoformat()`, and falls back to their own parser. ```python >>> datetime.datetime.fromisoformat("2012-04-23T10:20:30.400") datetime.datetime(2012, 4, 23, 10, 20, 30, 400000) >>> datetime.datetime.fromisoformat("2012-04-23T10:20:30.400 ") datetime.datetime(2012, 4, 23, 10, 20, 30, 40000) >>> datetime.datetime.fromisoformat("2012-04-23T10:20:30.400 ") datetime.datetime(2012, 4, 23, 10, 20, 30, 4000) >>> datetime.datetime.fromisoformat("2012-04-23T10:20:30.400 ") datetime.datetime(2012, 4, 23, 10, 20, 30, 400) >>> datetime.datetime.fromisoformat("2012-04-23T10:20:30.400 ") Traceback (most recent call last): File "<python-input-9>", line 1, in <module> datetime.datetime.fromisoformat("2012-04-23T10:20:30.400 ") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mgorny/git/cpython/Lib/_pydatetime.py", line 1949, in fromisoformat raise ValueError( f'Invalid isoformat string: {date_string!r}') from None ValueError: Invalid isoformat string: '2012-04-23T10:20:30.400 ' >>> datetime.datetime.fromisoformat("2012-04-23T10:20:30.400 +02:30") datetime.datetime(2012, 4, 23, 10, 20, 30, 40000, tzinfo=datetime.timezone(datetime.timedelta(seconds=9000))) ``` For comparison, the C extension rejects all variants containing spaces, causing Django to use its own parser. PyPy bug report: https://github.com/pypy/pypy/issues/5240 I'm going to try preparing a patch. ### CPython versions tested on: 3.11, 3.13, CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130962 * gh-131076 * gh-131086 <!-- /gh-linked-prs -->
33494b4d0dafc34ff4f1c118b7b3b5d8de3dd0f4
69309a55bcb5381a9a218edc910da135f4d67479
python/cpython
python__cpython-130958
# `test_concurrent_futures`: `test_free_reference` is flaky # Bug report Seen in https://buildbot.python.org/#/builders/1368/builds/2775/steps/6/logs/stdio The test attempts to ensure that the executor doesn't hold on to the result object, but the executor necessarily holds onto it for a brief period from when it sets the result in in the future until the variable goes out of scope. We should use `support.sleeping_retry` to check if the weakref eventually (ideally quickly) becomes dead. ``` ====================================================================== FAIL: test_free_reference (test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_free_reference) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/ec2-user/buildbot/buildarea/3.x.itamaro-macos-arm64-aws.macos-with-brew.refleak.nogil/build/Lib/test/test_concurrent_futures/executor.py", line 132, in test_free_reference self.assertIsNone(wr()) ~~~~~~~~~~~~~~~~~^^^^^^ AssertionError: <test.test_concurrent_futures.executor.MyObject object at 0x200041b0100> is not None ---------------------------------------------------------------------- ``` https://github.com/python/cpython/blob/12db45211d411583cbe272c7ba6811a811b721ca/Lib/test/test_concurrent_futures/executor.py#L125-L132 https://github.com/python/cpython/blob/12db45211d411583cbe272c7ba6811a811b721ca/Lib/concurrent/futures/thread.py#L85-L92 <!-- gh-linked-prs --> ### Linked PRs * gh-130958 * gh-131091 * gh-131092 <!-- /gh-linked-prs -->
19081158713526a3042c2ad3c6d5a589579b420f
44c55c23563fd27fced2ac575fd205f3e5c0a836
python/cpython
python__cpython-131041
# JIT: emit the AArch64 trampoline only when needed # Feature or enhancement ### Proposal: When emitting AArch64 trampoline we should check that the address we jump to is within 28bits range. If it is, we don't need the trampoline and we can jump directly to it. ### 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-131041 <!-- /gh-linked-prs -->
8a33034d82314e2a5a8f39f9348e93135f94807d
63a638c43f821e9c8b3256e7122c06e539dc585d
python/cpython
python__cpython-130955
# `test_multiprocessing_spawn.test_manager`: `test_notify_n` deadlock # Bug report Seen in https://buildbot.python.org/all/#/builders/1606/builds/220/steps/6/logs/stdio. This looks like the same type of failures as we had with `test_notify_all`. It would have been nice to fix it in https://github.com/python/cpython/pull/130933 together with `test_notify_all`, but in my limited local testing of `test_notify_n`, I didn't see any failures. ``` test_notify_n (test.test_multiprocessing_spawn.test_manager.WithManagerTestCondition.test_notify_n) ... Process Process-48: Traceback (most recent call last): File "/home/buildbot/buildarea/pull_request.itamaro-centos-aws.refleak.nogil/build/Lib/multiprocessing/process.py", line 313, in _bootstrap self.run() ~~~~~~~~^^ File "/home/buildbot/buildarea/pull_request.itamaro-centos-aws.refleak.nogil/build/Lib/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/buildbot/buildarea/pull_request.itamaro-centos-aws.refleak.nogil/build/Lib/test/_test_multiprocessing.py", line 1581, in f cond.release() ~~~~~~~~~~~~^^ File "/home/buildbot/buildarea/pull_request.itamaro-centos-aws.refleak.nogil/build/Lib/multiprocessing/managers.py", line 1066, in release return self._callmethod('release') ~~~~~~~~~~~~~~~~^^^^^^^^^^^ File "/home/buildbot/buildarea/pull_request.itamaro-centos-aws.refleak.nogil/build/Lib/multiprocessing/managers.py", line 847, in _callmethod raise convert_to_error(kind, result) multiprocessing.managers.RemoteError: --------------------------------------------------------------------------- Traceback (most recent call last): File "/home/buildbot/buildarea/pull_request.itamaro-centos-aws.refleak.nogil/build/Lib/multiprocessing/managers.py", line 263, in serve_client self.id_to_local_proxy_obj[ident] ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ KeyError: '200081100c0' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/buildbot/buildarea/pull_request.itamaro-centos-aws.refleak.nogil/build/Lib/multiprocessing/managers.py", line 265, in serve_client raise ke File "/home/buildbot/buildarea/pull_request.itamaro-centos-aws.refleak.nogil/build/Lib/multiprocessing/managers.py", line 259, in serve_client obj, exposed, gettypeid = id_to_obj[ident] ~~~~~~~~~^^^^^^^ KeyError: '200081100c0' --------------------------------------------------------------------------- Timeout (0:45:00)! Thread 0x00007fce16a26740 (most recent call first): ``` <!-- gh-linked-prs --> ### Linked PRs * gh-130955 * gh-130981 * gh-130982 <!-- /gh-linked-prs -->
edd1eca336976b3431cf636aea87f08a40c94935
72e5b25efb580fb1f0fdfade516be90d90822164
python/cpython
python__cpython-130948
# PyQt6 uses PySequence_Fast() which was removed from the limited C API 3.14 # Bug report ### Bug description: In the issue https://github.com/python/cpython/issues/91417 I removed PySequence_Fast(), commit 2ad069d906c6952250dabbffbcb882676011b310: > Remove PySequence_Fast() from the limited C API. The function never worked with the limited C API. It was added by mistake. Problem: PyQt6 uses the function! I propose to add back PySequence_Fast() to the limited C API. PyQt6: ``` ./qpy/QtOpenGL/qpyopengl_attribute_array.cpp: values = PySequence_Fast(values, "an attribute array must be a sequence"); ./qpy/QtOpenGL/qpyopengl_attribute_array.cpp: itm = PySequence_Fast(itm, ./qpy/QtOpenGL/qpyopengl_uniform_value_array.cpp: values = PySequence_Fast(values, ./qpy/QtOpenGL/qpyopengl_uniform_value_array.cpp: itm = PySequence_Fast(itm, ./qpy/QtOpenGL/qpyopengl_value_array.cpp: PyObject *seq = PySequence_Fast(values, ``` They reimplemented PySequence_Fast_GET_SIZE() and PySequence_Fast_GET_ITEM() macros which don't work with the limited C API: ```c // Replacements for the corresponding Python macros that use the limited API. #define Sequence_Fast_Size(o) \ (PyList_Check(o) ? PyList_Size(o) : PyTuple_Size(o)) #define Sequence_Fast_GetItem(o, i)\ (PyList_Check(o) ? PyList_GetItem(o, i) : PyTuple_GetItem(o, i)) ``` ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130948 <!-- /gh-linked-prs -->
10cbd1fe88d1095a03cce24fb126d479668a67c3
3a189af4b203b9b3bd466680161b32016502defb
python/cpython
python__cpython-130949
# configparser throws TypeError for combination of interpolation and allow_no_value # Bug report ### Bug description: The configparser modules throws an Exception as: ``` Traceback (most recent call last): File "test.py", line 4, in <module> config.get("dummy", "b") File "python3.12/configparser.py", line 777, in get return self._interpolation.before_get(self, section, option, value, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "python3.12/configparser.py", line 428, in before_get self._interpolate_some(parser, option, L, value, section, defaults, 1) File "python3.12/configparser.py", line 481, in _interpolate_some if "$" in v: ^^^^^^^^ TypeError: argument of type 'NoneType' is not iterable ``` when using: **config.ini** ```ini [dummy] a b = ${a} ``` and following ConfigParser settings: **test.py** ```python import configparser config = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation(), allow_no_value=True) config.read("config.ini") config.get("dummy", "b") ``` Since the value of a is None the interpolation should convert the reference first to an empty string to keep interpolation alive. Expected value for b would be an empty string. ### CPython versions tested on: 3.12, 3.13 ### Operating systems tested on: Linux, Windows <!-- gh-linked-prs --> ### Linked PRs * gh-130949 * gh-132588 <!-- /gh-linked-prs -->
c35c7353eb8fbccff2d3a6ab664426b31af00d4d
8b7cb947c5046d8fb32aad532048de87e09ed3f9
python/cpython
python__cpython-130934
# `_PyModule_IsPossiblyShadowing` can return `-1` without an exception set # Bug report ### Bug description: This can lead to an assertion failure: ``` #6 0x00007ffff7ca9e96 in __GI___assert_fail (assertion=0x555555a5e2da "PyErr_Occurred()", file=0x555555a6edcd "Objects/object.c", line=1253, function=0x555555a6f36e "int _PyObject_SetAttributeErrorContext(PyObject *, PyObject *)") at ./assert/assert.c:101 #7 0x00005555557273ac in _PyObject_SetAttributeErrorContext (v=<module at remote 0x200009a1a50>, name='getaliases') at Objects/object.c:1253 #8 0x0000555555726dde in PyObject_GetAttr (v=<module at remote 0x200009a1a50>, name='getaliases') at Objects/object.c:1306 #9 0x0000555555727de6 in _PyObject_GetMethod (obj=<module at remote 0x200009a1a50>, name='getaliases', method=0x7ffffffdb1b8) at Objects/object.c:1581 #10 0x000055555588456d in _PyEval_EvalFrameDefault (tstate=0x555555d16fb0 <_PyRuntime+360560>, frame=0x7ffff7f9cf20, throwflag=0) at Python/generated_cases.c.h:7682 ``` `_Py_wgetcwd` does not set an exception on failure: https://github.com/python/cpython/blob/a025f27d94afe732be2e9e6f05b9007d04f983a8/Objects/moduleobject.c#L923-L924 Likely related to https://github.com/python/cpython/issues/95754 cc @hauntsaninja ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130934 * gh-130939 * gh-131037 * gh-131073 <!-- /gh-linked-prs -->
0a9ae5ed48e6ea078f67ba03635c1c26209b5def
8190571a75fc46278042e7fffbe8aeb1f71ab21d
python/cpython
python__cpython-130967
# Not accurate when outputting an error during byte formatting for the 'i' flag, the 'd' flag is output, which can be misleading # Bug report ### Bug description: Code for demonstration: ```python >>> b"%i" % "str" Traceback (most recent call last): File "<python-input-0>", line 1, in <module> b"%i" % "str" ~~~~~~^~~~~~~ TypeError: %d format: a real number is required, not str ``` Expected error message text: ```python TypeError: %i format: a real number is required, not str ``` Also for strings this message is output correctly: ```python >>> "%i" % "str" Traceback (most recent call last): File "<python-input-1>", line 1, in <module> "%i" % "str" ~~~~~^~~~~~~ TypeError: %i format: a real number is required, not str ``` I would like to send a PR to fix this. ### CPython versions tested on: 3.12, 3.13, 3.14, CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130967 <!-- /gh-linked-prs -->
7c3692fe275088e986f92cec34dcccb823b31fa2
929afd1d6ee4fb89ac818037effe6577947103de
python/cpython
python__cpython-131843
# Local annotation turns local variables in cells # Bug report ### Bug description: Compiling this function ```python def f(x): a:x return x ``` Gives this bytecode: ``` -- MAKE_CELL 0 (x) 1 RESUME 0 3 LOAD_DEREF 0 (x) RETURN_VALUE ``` Local variable annotations are supposed to be ignored by Python (they are used by static type checkers only), so the addition of the annotation should not change the generated code. The expected disassembly: ``` 1 RESUME 0 3 LOAD_LAST 0 (x) RETURN_VALUE ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131843 <!-- /gh-linked-prs -->
425f60b9eb253c57bc32b453a02f1cf09963f85a
c6b1a073438d93d4e62957accc73487df6711851
python/cpython
python__cpython-130923
# TSAN complains on free-threaded list operations # Bug report ### Bug description: Discovered a case where TSAN complains about list operations in free-threaded build and posting it here on the suggestion of @colesbury. Reproducer: ``` import threading def copy_back_and_forth(b, a, count): b.wait() for _ in range(count): a[0] = a[1] a[1] = a[0] def check(funcs, *args): barrier = threading.Barrier(len(funcs)) thrds = [] for func in funcs: thrd = threading.Thread(target=func, args=(barrier, *args)) thrds.append(thrd) thrd.start() for thrd in thrds: thrd.join() if __name__ == "__main__": check([copy_back_and_forth] * 10, [0, 1], 100) ``` Error (also happens in the other direction, write after read): ``` WARNING: ThreadSanitizer: data race (pid=192991) Atomic read of size 8 at 0x7f2d7a2b6260 by thread T10: #0 __tsan_atomic64_load ../../../../src/libsanitizer/tsan/tsan_interface_atomic.cpp:539 (libtsan.so.0+0x7fe0e) #1 _Py_atomic_load_ptr Include/cpython/pyatomic_gcc.h:300 (python+0x20434f) #2 _Py_TryXGetRef Include/internal/pycore_object.h:649 (python+0x20434f) #3 list_get_item_ref Objects/listobject.c:364 (python+0x20434f) #4 _PyList_GetItemRef Objects/listobject.c:415 (python+0x20a568) #5 _PyEval_EvalFrameDefault Python/generated_cases.c.h:686 (python+0x41e893) #6 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x46da1b) #7 _PyEval_Vector Python/ceval.c:1820 (python+0x46da1b) #8 _PyFunction_Vectorcall Objects/call.c:413 (python+0x188ec4) #9 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x190b3c) #10 method_vectorcall Objects/classobject.c:72 (python+0x190b3c) #11 _PyVectorcall_Call Objects/call.c:273 (python+0x18c9b7) #12 _PyObject_Call Objects/call.c:348 (python+0x18ceaf) #13 PyObject_Call Objects/call.c:373 (python+0x18cf34) #14 thread_run Modules/_threadmodule.c:354 (python+0x6689f2) #15 pythread_wrapper Python/thread_pthread.h:242 (python+0x57d03b) Previous write of size 8 at 0x7f2d7a2b6260 by thread T2: #0 PyList_SET_ITEM Include/cpython/listobject.h:47 (python+0x40aa3c) #1 _PyEval_EvalFrameDefault Python/generated_cases.c.h:11260 (python+0x466be8) #2 _PyEval_EvalFrame Include/internal/pycore_ceval.h:116 (python+0x46da1b) #3 _PyEval_Vector Python/ceval.c:1820 (python+0x46da1b) #4 _PyFunction_Vectorcall Objects/call.c:413 (python+0x188ec4) #5 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x190b3c) #6 method_vectorcall Objects/classobject.c:72 (python+0x190b3c) #7 _PyVectorcall_Call Objects/call.c:273 (python+0x18c9b7) #8 _PyObject_Call Objects/call.c:348 (python+0x18ceaf) #9 PyObject_Call Objects/call.c:373 (python+0x18cf34) #10 thread_run Modules/_threadmodule.c:354 (python+0x6689f2) #11 pythread_wrapper Python/thread_pthread.h:242 (python+0x57d03b) ``` Relevant locations in files: Write: https://github.com/python/cpython/blob/052cb717f5f97d08d2074f4118fd2c21224d3015/Python/generated_cases.c.h#L11262 Read: https://github.com/python/cpython/blob/052cb717f5f97d08d2074f4118fd2c21224d3015/Python/generated_cases.c.h#L686 What is happening probably is that the read is a lock-free read which occurs in the other thread between the `PyList_SET_ITEM()` and the `UNLOCK_OBJECT()`. In order to avoid TSAN complaining here either the `PyList_SET_ITEM()` and the read would have to be atomic, or the read would have to be locked with a mutex (negating the point of lock-free). The thing is as far as I see the worst thing that will happen on the read side is it will get a stale value from the list. Which since there is not a defined order between the threads is harmless since the read can easily have happened before the modification or after regardless. So is this an issue and should the write (and read) be made atomic during lock-free operation (or some other correction applied)? ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130923 <!-- /gh-linked-prs -->
a025f27d94afe732be2e9e6f05b9007d04f983a8
6c6600f6831aec15b2acbd7a9bb9c275bd5f4a32
python/cpython
python__cpython-130918
# test_signal.test_itimer_virtual times out on macOS # Bug report ### Bug description: The test `test_signal.test_itimer_virtual` fails (in TIMEOUT) on our internal CI mac infrastructure (and also on my mac used for development) ``` [2025-03-06T12:21:58.340Z] Re-running test_signal in verbose mode (matching: test_itimer_virtual) [2025-03-06T12:21:58.340Z] test_itimer_virtual (test.test_signal.ItimerTest.test_itimer_virtual) ... FAIL [2025-03-06T12:21:58.340Z] [2025-03-06T12:21:58.340Z] ====================================================================== [2025-03-06T12:21:58.340Z] FAIL: test_itimer_virtual (test.test_signal.ItimerTest.test_itimer_virtual) [2025-03-06T12:21:58.340Z] ---------------------------------------------------------------------- [2025-03-06T12:21:58.340Z] Traceback (most recent call last): [2025-03-06T12:21:58.340Z] File "/Users/bot/workspace/workspace/enterprise-llt-gerrit-pipeline/src/cpython/Lib/test/test_signal.py", line 843, in test_itimer_virtual [2025-03-06T12:21:58.340Z] for _ in support.busy_retry(support.LONG_TIMEOUT): [2025-03-06T12:21:58.340Z] ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ [2025-03-06T12:21:58.340Z] File "/Users/bot/workspace/workspace/enterprise-llt-gerrit-pipeline/src/cpython/Lib/test/support/__init__.py", line 2544, in busy_retry [2025-03-06T12:21:58.340Z] raise AssertionError(msg) [2025-03-06T12:21:58.340Z] AssertionError: timeout (300.0 seconds) [2025-03-06T12:21:58.340Z] [2025-03-06T12:21:58.340Z] ---------------------------------------------------------------------- [2025-03-06T12:21:58.340Z] Ran 1 test in 300.002s ``` The timer doesn't get stopped by the signal. This if statement https://github.com/python/cpython/blob/9c691500f9412ecd8f6221c20984dc7a55a8a9e8/Lib/test/test_signal.py#L846 is never True and it goes in timeout. https://github.com/python/cpython/blob/9c691500f9412ecd8f6221c20984dc7a55a8a9e8/Lib/test/test_signal.py#L845 The reason behind this is the workload simulated is too lightweight to advance the virtual timer. I see for now this just on macOS but it could potentially happens on other platforms as well. ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-130918 * gh-130968 * gh-130969 <!-- /gh-linked-prs -->
78790811989ab47319e2ee725e0c435b3cdd21ab
b1b4f9625c5f2a6b2c32bc5ee91c9fef3894b5e6
python/cpython
python__cpython-131317
# graphlib.TopologicalSorter.prepare() should be idempotent # Feature or enhancement ### Proposal: ## Proposed Behaviour [`TopologicalSorter.prepare()`](https://docs.python.org/3/library/graphlib.html#graphlib.TopologicalSorter.prepare) should be idempotent such that calling it repeatedly without draining anything is not an error: ```python >>> import graphlib >>> ts = graphlib.TopologicalSorter() >>> ts.prepare() >>> ts.prepare() ``` If you have called `.get_ready()`/`.done()` then calling `prepare()` is probably a programming error and this would raise: ```python >>> import graphlib >>> ts = graphlib.TopologicalSorter() >>> ts.prepare() >>> ts.get_ready() () >>> ts.prepare() Traceback (most recent call last): ... ValueError: cannot prepare() after mutating prepared sorter ``` ## Rationale `TopologicalSorter.prepare()` raises an exception if you call it twice: ```python >>> import graphlib >>> ts = graphlib.TopologicalSorter() >>> ts.prepare() >>> ts.prepare() Traceback (most recent call last): File "<python-input-3>", line 1, in <module> ts.prepare() ~~~~~~~~~~^^ File "/home/mauve/.local/share/ext-python/python-3.13.0.82/lib/python3.13/graphlib.py", line 95, in prepare raise ValueError("cannot prepare() more than once") ValueError: cannot prepare() more than once ``` This is rather unfortunate because if you return a `TopologicalSorter` that is prepared: ```python def get_sorter(targets) -> TopologicalSorter[str]: """Get a TopologicalSorter that pursues the given targets.""" deps = filter_deps(load_deps(), targets) ts = TopologicalSorter(deps) ts.prepare() return ts ``` because then you cannot run `.static_order()` on it: ```python >>> get_sorter().static_order() Traceback (most recent call last): ... ValueError: cannot prepare() more than once ``` while if you don't `prepare()`, you then require the caller to do it, meaning the function that populates and returns a `TopologicalSorter` didn't leave it in a prepared state. It seems appropriate for such a function to call `prepare()` in order to leave the TopologicalSorter ready to iterate and also closed for the addition of new nodes/predecessors. Therefore I think `prepare()` should be idempotent. ### 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: This is related to #91301 which discusses removing `TopologicalSorter.prepare()` entirely. Doing so would bypass this issue. <!-- gh-linked-prs --> ### Linked PRs * gh-131317 <!-- /gh-linked-prs -->
c1b42db9e47b76fca3c2993cb172cc4991b04839
f81990024554a75e2ab31133a72d9f0954690435
python/cpython
python__cpython-131550
# PEP 649 behavior for partially executed modules # Bug report ### Bug description: Consider this package: ``` $ ls recmod/ __main__.py a.py b.py $ cat recmod/__main__.py from . import a print(a.__annotations__) $ cat recmod/a.py v1: int from . import b v2: int $ cat recmod/b.py from . import a print(a.__annotations__) ``` On 3.13, this produces: ``` $ python3.13 -m recmod {'v1': <class 'int'>} {'v1': <class 'int'>, 'v2': <class 'int'>} ``` But on main, we get this: ``` $ ~/py/cpython/python.exe -m recmod {} {} ``` This is because we only set the `__annotate__` function at the end of the module execution, so when we access annotations on the partially executed module a (in `b.py`), there aren't any yet. But this also populates the `__annotations__` cache, so even accesses to `__annotations__` after a has been fully executed still return an empty dictionary. Should we fix this and how? I don't care much what happens if you access `__annotations__` while the module is partially evaluated. However, it seems bad that such access poisons the cache forever. To fix that, we should make `ModuleType.__annotations__` not cache its return value if the module is not yet fully evaluated. ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-131550 <!-- /gh-linked-prs -->
922049b613d155ade4c4a8f83452767bea003a9f
5bf0f3666e272798789ff900b1071760c73b46fd
python/cpython
python__cpython-130904
# Typo in `_GUARD_BOTH_UNICODE` dsl # Bug report ### Bug description: There appears to be a typo in the `optimizer_bytecodes` for `_GUARD_BOTH_UNICODE` where the right operand is not getting checked: https://github.com/python/cpython/blob/5e73ece95e8aa92d0695acb039ef54e2103ce66b/Python/optimizer_bytecodes.c#L163-L169 Original change from gh-118910: https://github.com/python/cpython/pull/118913/files#diff-e5bd2b14b0b10f0f47786e26306d689ed1361c3dc3b11dcc3ea52b8a2422ff64L151-R141 N.b. I'm not very familiar with this part of the code-base and just happened to stumble upon this when studying through it; apologies if I misunderstood something 🙏 ### CPython versions tested on: 3.14, CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130904 <!-- /gh-linked-prs -->
10cdd7f91ff45737e409a2e2c58fd8a9aa7c5a16
aeb23273867b27818a3dabd5fca086a1a2e8d229
python/cpython
python__cpython-130894
# Typo in sqlite3.__main__.SqliteInteractiveConsole # Documentation The docstring for sqlite3.\_\_main\_\_.SqliteInteractiveConsole.runsource is ``` """Override runsource, the core of the InteractiveConsole REPL. Return True if more input is needed; buffering is done automatically. Return False is input is a complete statement ready for execution. """ ``` In the last line, it should say "Return False **if** input is a complete...", not **is**. <!-- gh-linked-prs --> ### Linked PRs * gh-130894 <!-- /gh-linked-prs -->
8190571a75fc46278042e7fffbe8aeb1f71ab21d
886a4d74ee7b19d027fae1ba4579a99a805878a2
python/cpython
python__cpython-131042
# JIT: remove jumps at the end of every micro op on aarch64 # Feature or enhancement ### Bug description: AArch64 JIT stencils contain a jump at the end of every micro op: ``` ... // d4: a8c17bfd ldp x29, x30, [sp], #0x10 // d8: 14000000 b 0xd8 <_JIT_ENTRY+0xd8> // 00000000000000d8: R_AARCH64_JUMP26 _JIT_CONTINUE ``` These jumps need to be removed and replaced with no-ops to keep the alignment of 8 bytes. Also the current padding mechanism needs to be removed as well. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131042 <!-- /gh-linked-prs -->
ea0453ee979174d6fc14aae0fd85e4ede6742a86
0a91456ad14bb598646f50bf8f034e8887c0c468
python/cpython
python__cpython-130935
# conditional blocks in class definitions seem to be evaluating types even when these conditionals are false # Bug report ### Bug description: using a conditional in a class definition like `if TYPE_CHECKING` where `TYPE_CHECKING` is False, or any kind of false conditional, seems to be ignored when types are evaluated under non-future annotations mode: ```python class MyClass: somevalue: str if False: someothervalue: int assert MyClass.__annotations__ == {"somevalue": str}, f"MyClass.__annotations__ == {MyClass.__annotations__}" ``` this seems to be something that might have been done with [some intention](https://peps.python.org/pep-0749/), which is extremely troubling as this would be a huge showstopper for SQLAlchemy if these conditionals are no longer honored at runtime. A similar example ```py from typing import TYPE_CHECKING if TYPE_CHECKING: # is not evaluated under any python at runtime from some_module import SpecialType class MyClass: somevalue: str if TYPE_CHECKING: # **is** evaluated under python 3.14.0a5, fails someothervalue: SpecialType assert MyClass.__annotations__ == {"somevalue": str}, f"MyClass.__annotations__ == {MyClass.__annotations__}" ``` calling upon `__annotations__` seems to be the trigger that makes the above fail: ```py Traceback (most recent call last): File "/home/classic/dev/sqlalchemy/test4.py", line 14, in <module> assert MyClass.__annotations__ == {"somevalue": str}, f"MyClass.__annotations__ == {MyClass.__annotations__}" ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/classic/dev/sqlalchemy/test4.py", line 12, in __annotate__ someothervalue: SpecialType ^^^^^^^^^^^ NameError: name 'SpecialType' is not defined ``` however this appears to be some very strange quantum-physics type of evaluation that isn't actually running Python fully; below, the "someothervalue" type is evaluted, but not the value function assigned! ```py from typing import TYPE_CHECKING def do_my_thing() -> int: print("HEY!") assert False return 3 + 4 class MyClass: somevalue: str if TYPE_CHECKING: someothervalue: int = do_my_thing() assert MyClass.__annotations__ == {"somevalue": str}, f"MyClass.__annotations__ == {MyClass.__annotations__}" ``` This is an enormous and strange behavioral change that is really going to make things extremely difficult for SQLAlchemy, starting with we will have to rewrite ~~thousands~~ (OK, it turned out to be "dozens") of lines of test suite code into a much bigger exploded form and also a lot of end-user use cases we've defined using TYPE_CHECKING blocks aren't going to work anymore, it's not clear how much further this change will go. I suppose if the whole thing boils down to what `__annotations__` does, and we can call upon something like `__annotations_but_not_false_blocks__`, that could save us, but overall I'm really hoping this is just a bad dream that we can wake up from. ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130935 <!-- /gh-linked-prs -->
898e6b395e63ad7f8bbe421adf0af8947d429925
7bb41aef4b7b8f3c3f07c11b801c5b7f8afaac7f
python/cpython
python__cpython-130879
# PCBuild ssl restore some functionaly # Bug report ### Bug description: My changes is work around this commit - https://github.com/python/cpython/commit/8c9d99ff2227d7a069b29f26004f33d65a1df177 Old realization uses `(exit_ok=True)` which raise exceptions only if `errno` == `EEXIST`. => We get exception only if dir not exists Now realization uses default `exit_ok=False`, which means we raise exception on every `errno`. And just pass it. I suggest to add check. For example if dir is already exists - pass, if we have some problems (for example - no rights for create dir etc) - raise exception and exit. I'll prepare PR ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-130879 <!-- /gh-linked-prs -->
2904ec2273762df58645a8e245b2281884855b8c
4f6218959e35f649061484cce9de7fc810586533
python/cpython
python__cpython-131098
# Perf doesn't show the Python functions when using the -O0 compilation flag without frame pointers # Bug report ### Bug description: When compiling without frame pointers and the -O0 optimization flag, Perf cannot see the Python functions. This is not the case when using -O3, -O2, -O1, -Og or when enabling frame pointers. Tested on both x86_64 and aarch64. Perf 6.13.4, GDB 16.2, GCC 14.2.1 on x86_64/aarch64, Fedora 41. To reproduce: `./configure --enable-shared --without-static-libpython && CFLAGS="-O0" make` `LD_LIBRARY_PATH=$PWD perf record -F 9999 -g -k 1 --call-graph dwarf -o perf.data ./python -Xperf_jit script_from_python_perf_docs.py` `perf inject -i perf.data --jit --output perf.jit.data` `perf report -g -i perf.jit.data` ### CPython versions tested on: CPython main branch, 3.14, 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131098 * gh-132687 <!-- /gh-linked-prs -->
d134bd272f90bfc2dfb55b126d4552c996251fc1
b9f0943c1e31acd0895a4b57b4af57a5a1e0a2b1
python/cpython
python__cpython-130865
# Thousands separators in fractional part are ignored in width computation # Bug report ### Bug description: Examples: ```pycon >>> f"{0.1234567891:010.6,f}" # should be '00.123,457' '000.123,457' >>> len(_) 11 >>> f"{0.1234567891:010.7,f}" # should be '0.123,456,8' '00.123,456,8' >>> len(_) 12 ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130865 <!-- /gh-linked-prs -->
2352bd418a7a0c38f8ea135bd1879937d90ecce1
10cdd7f91ff45737e409a2e2c58fd8a9aa7c5a16
python/cpython
python__cpython-130853
# Python 3.13t crashes when constructing code objects with non-standard constants # Bug report PyTorch Dynamo constructs code objects with non-standard constants. This is unusual, but seems to work with the default (non-free threaded build) of CPython. However, it crashes in the free threaded build due to a few assertions when we try to de-dupe (intern) and immortalize constants: In `compare_constants`: https://github.com/python/cpython/blob/3dd3675492a3fc3b7996613ef75a9044ee7449b0/Objects/codeobject.c#L2671-L2672 In `hash_const: https://github.com/python/cpython/blob/3dd3675492a3fc3b7996613ef75a9044ee7449b0/Objects/codeobject.c#L2692-L2694 We should more gracefully handle unexpected code object constants in the free threading build. I think the interning code should behave like `_PyCode_ConstantKey()` where unhandled objects types are treated as unequal if they are not the same instance (i.e., identity comparison for unexpected types). cc @williamwen42 <!-- gh-linked-prs --> ### Linked PRs * gh-130853 * gh-130880 * gh-130899 * gh-130901 * gh-130953 <!-- /gh-linked-prs -->
2905690a91bf72cdf0fb919b5193849bb67732e2
78d50e91ff31bc7fd0ac877cf59ee083e94d0915
python/cpython
python__cpython-130828
# PyLong_AsLongAndOverflow does not guarantee overflow is -1 when value is -1 # Bug report ### Bug description: In the function `pylong_aslongandoverflow` https://github.com/python/cpython/blob/3929af5e3a203291dc07b40c9c3515492e3ba7b4/Modules/_testlimitedcapi/long.c#L621-L632 there is an assertion `overflow == -1` when `value == -1`. But this is not always true, like if `arg` is `NULL`. Reproduce: ```python from test.support import import_helper _testlimitedcapi = import_helper.import_module('_testlimitedcapi') aslonglongandoverflow = _testlimitedcapi.pylong_aslonglongandoverflow aslonglongandoverflow(None) ``` Result: ``` python: ../Modules/_testlimitedcapi/long.c:674: pylong_aslonglongandoverflow: Assertion `overflow == -1' failed. ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130828 * gh-130869 * gh-130871 * gh-130876 <!-- /gh-linked-prs -->
90130807d9c5a55b2a64024f5dfbee4785b9a27c
e53d105872fafa77507ea33b7ecf0faddd4c3b60
python/cpython
python__cpython-130817
# Fix the title of "Type Objects" page # Documentation [Type Objects](https://docs.python.org/3/c-api/typeobj.html) and [Type Objects](https://docs.python.org/3/c-api/type.html) have the same page title even though their contents are different. For consistency with other pages, the title of the former page might be something like "Type Object Structures". <!-- gh-linked-prs --> ### Linked PRs * gh-130817 * gh-131224 * gh-131225 <!-- /gh-linked-prs -->
6b932edc5216d9766e70fef300a6b842ab33204c
a5776639c8fde8b3b7c90821ab78ddb64130f4c0
python/cpython
python__cpython-130905
# Emit ResourceWarning when GzipFile is deleted with unwritten data # Feature or enhancement ### Proposal: This may indicate accidental data loss. Ways to make sure all data is written: 1. Use the [file-like object](https://docs.python.org/3/glossary.html#term-file-object) as a [“With Statement Context Manager”](https://docs.python.org/3/reference/datamodel.html#context-managers). - All objects which [inherit](https://docs.python.org/3/tutorial/classes.html#inheritance) from [IOBase](https://docs.python.org/3/library/io.html#io.IOBase) support this. - [`BufferedIOBase`](https://docs.python.org/3/library/io.html#io.BufferedIOBase), [`BufferedWriter`](https://docs.python.org/3/library/io.html#io.BufferedWriter), and [`GzipFile`](https://docs.python.org/3/library/gzip.html#gzip.GzipFile) all support this. - Ensures `.close()` is called in both exception and regular cases. 1. Ensure [`.close()`](https://docs.python.org/3/library/io.html#io.IOBase.close) is always called which flushes data before closing. 1. If the underlying stream need to be kept open, use [`.detach()`](https://docs.python.org/3/library/io.html#io.BufferedIOBase.detach) Since 3.12 flushing has been necessary in GzipFile (see gh-105808 which was a release blocker), this makes that more visible. Users have been encountering as they upgrade to 3.12 (ex. gh-129726). There are a number of cases of unclosed file-like objects being deleted in CPython libraries and the test suite. This issue includes resolving those cases where the new ResourceWarning is emitted. cc: @vstinner ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: https://github.com/python/cpython/issues/129726#issuecomment-2690022926 <!-- gh-linked-prs --> ### Linked PRs * gh-130905 <!-- /gh-linked-prs -->
93089c073661f5aa9f8cca574a3e223716728639
d12d8c50cddeb79f8d6e3d26a33f8f6b14bb4071
python/cpython
python__cpython-130805
# [Windows] New REPL doesn't allow to input non-ASCII Unicode characters # Bug report ### Bug description: I got following error when I tried to type Cyrillic characters (tried ч in this example) in the new repl: ```pytb .\python.bat Running Release|x64 interpreter... Python 3.14.0a5+ (heads/main-dirty:d0eb01c9de9, Mar 3 2025, 23:39:38) [MSC v.1942 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> x Traceback (most recent call last): File "<python-input-0>", line 1, in <module> x NameError: name 'x' is not defined >>> Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "D:\Sources\_pythonish\cpython\Lib\_pyrepl\__main__.py", line 6, in <module> __pyrepl_interactive_console() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "D:\Sources\_pythonish\cpython\Lib\_pyrepl\main.py", line 59, in interactive_console run_multiline_interactive_console(console) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Sources\_pythonish\cpython\Lib\_pyrepl\simple_interact.py", line 143, in run_multiline_interactive_console statement = multiline_input(more_lines, ps1, ps2) File "D:\Sources\_pythonish\cpython\Lib\_pyrepl\readline.py", line 389, in multiline_input return reader.readline() ~~~~~~~~~~~~~~~^^ File "D:\Sources\_pythonish\cpython\Lib\_pyrepl\reader.py", line 802, in readline self.handle1() ~~~~~~~~~~~~^^ File "D:\Sources\_pythonish\cpython\Lib\_pyrepl\reader.py", line 758, in handle1 event = self.console.get_event(block=False) File "D:\Sources\_pythonish\cpython\Lib\_pyrepl\windows_console.py", line 472, in get_event self.event_queue.push(rec.Event.KeyEvent.uChar.UnicodeChar) ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Sources\_pythonish\cpython\Lib\_pyrepl\base_eventqueue.py", line 77, in push char = bytes(bytearray((ord_char,))) ~~~~~~~~~^^^^^^^^^^^^^ ValueError: byte must be in range(0, 256) ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-130805 * gh-133462 <!-- /gh-linked-prs -->
7c98b0674daa3e4eb3e8f35afb61a0dba61d1780
6ab5c4aa05bf35832a3ccd1e71b28b8475fa30f4
python/cpython
python__cpython-130808
# Free-threading QSBR delayed free mem fails in high thread turnover environment # Crash report ### What happened? When cycling a lot of threads and modifying objects which use `PyMem_FreeDelayed()` in those threads the queues of memory blocks to free build up without ever being freed until the process runs out of memory, unless something else causes them to be freed. For example in the reproducer below commenting in the `gc.collect()` or the `for` loop will cause the delayed blocks to be freed correctly. Note that this is an extreme case. Reproducer: ```python import gc import threading def fupmem(b, l): b.wait() l *= 2 def check(funcs, *args): barrier = threading.Barrier(len(funcs)) thrds = [] for func in funcs: thrd = threading.Thread(target=func, args=(barrier, *args)) thrds.append(thrd) thrd.start() for thrd in thrds: thrd.join() if __name__ == "__main__": count = 0 while True: print(count := count + 1) check([fupmem] * 10, [None] * 256) # gc.collect() # for i in range(1000): # l = [] # del l ``` ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.14.0a5+ experimental free-threading build (heads/main:b3c18bfd828, Mar 3 2025, 09:13:46) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-130808 * gh-130857 <!-- /gh-linked-prs -->
2f6e0e9f7001769be746ee96356656d3ebdc7f96
cb67b44ca92f9930b3aa2aba8420c89d12a25303
python/cpython
python__cpython-130801
# Remove references to Unicode objects being ready We have some code referrencing readiness of Unicode objects but this property is deprecated (see https://github.com/python/cpython/issues/129894#issuecomment-2693828966). Following @encukou's advice, we should address each module with a separate PR so that experts can review them separately. ### `unicodedata.c` https://github.com/python/cpython/blob/a85eeb97710617404ba7a0fac3b264f586caf70c/Modules/unicodedata.c#L594-L596 https://github.com/python/cpython/blob/a85eeb97710617404ba7a0fac3b264f586caf70c/Modules/unicodedata.c#L655-L661 ### `_io/textio.c` https://github.com/python/cpython/blob/a85eeb97710617404ba7a0fac3b264f586caf70c/Modules/_io/textio.c#L357-L363 https://github.com/python/cpython/blob/a85eeb97710617404ba7a0fac3b264f586caf70c/Modules/_io/textio.c#L1821-L1824 ### `Parser` files https://github.com/python/cpython/blob/a85eeb97710617404ba7a0fac3b264f586caf70c/Parser/lexer/lexer.c#L311-L315 https://github.com/python/cpython/blob/a85eeb97710617404ba7a0fac3b264f586caf70c/Parser/pegen.c#L505-L513 ### `tracemalloc.c` https://github.com/python/cpython/blob/a85eeb97710617404ba7a0fac3b264f586caf70c/Python/tracemalloc.c#L252-L259 This one seems to be dead code (cc @vstinner) <!-- gh-linked-prs --> ### Linked PRs * gh-130801 <!-- /gh-linked-prs -->
3a7f17c7e2f72a836a019c316818c446a0c71d75
8a64a62002fa3cdc93cb4cfee315edb235cad8cb
python/cpython
python__cpython-130795
# Crash in Python/assemble.c:301: write_location_info_entry: Assertion `column >= -1' failed. # Crash report ### What happened? ## Bug Description This is a bug that only affects DEBUG builds. The reproducer is as follow: ```python import ast tree = ast.Module(body=[ ast.Import(names=[ast.alias(name='traceback', lineno=0, col_offset=0)], lineno=0, col_offset=-2) ], type_ignores=[]) compile(tree, "<string>", "exec") ``` This code fails with: ``` python: ../Python/assemble.c:301: write_location_info_entry: Assertion `column >= -1' failed. fish: Job 1, '/home/yijan/Tools/cpython/debug…' terminated by signal SIGABRT (Abort) ``` ## backtrace ``` #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3 0x00007ffff6c4527e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4 0x00007ffff6c288ff in __GI_abort () at ./stdlib/abort.c:79 #5 0x00007ffff6c2881b in __assert_fail_base (fmt=0x7ffff6dd01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x555557212940 "column >= -1", file=file@entry=0x555557211f60 "../Python/assemble.c", line=line@entry=301, function=function@entry=0x555557213040 <__PRETTY_FUNCTION__.11> "write_location_info_entry") at ./assert/assert.c:96 #6 0x00007ffff6c3b517 in __assert_fail (assertion=assertion@entry=0x555557212940 "column >= -1", file=file@entry=0x555557211f60 "../Python/assemble.c", line=line@entry=301, function=function@entry=0x555557213040 <__PRETTY_FUNCTION__.11> "write_location_info_entry") at ./assert/assert.c:105 #7 0x0000555556bc1760 in write_location_info_entry (a=a@entry=0x7ffff4727fb0, loc=..., isize=isize@entry=6) at ../Python/assemble.c:301 #8 0x0000555556bc1974 in assemble_emit_location (a=a@entry=0x7ffff4727fb0, loc=..., isize=isize@entry=6) at ../Python/assemble.c:336 #9 0x0000555556bc1d36 in assemble_location_info (a=a@entry=0x7ffff4727fb0, instrs=instrs@entry=0x7ffff48c3840, firstlineno=<optimized out>) at ../Python/assemble.c:355 #10 0x0000555556bc487b in assemble_emit (a=a@entry=0x7ffff4727fb0, instrs=instrs@entry=0x7ffff48c3840, first_lineno=<optimized out>, const_cache=const_cache@entry=0x50800009e040) at ../Python/assemble.c:433 #11 0x0000555556bc4cd9 in _PyAssemble_MakeCodeObject (umd=umd@entry=0x51900008e710, const_cache=const_cache@entry=0x50800009e040, consts=consts@entry=0x5070001d8d80, maxdepth=maxdepth@entry=2, instrs=instrs@entry=0x7ffff48c3840, nlocalsplus=nlocalsplus@entry=0, code_flags=<optimized out>, filename=<optimized out>) at ../Python/assemble.c:752 #12 0x0000555556cf6ba8 in optimize_and_assemble_code_unit (u=u@entry=0x51900008e390, const_cache=const_cache@entry=0x50800009e040, code_flags=code_flags@entry=0, filename=filename@entry=0x50700011db30) at ../Python/compile.c:1341 #13 0x0000555556cfe374 in _PyCompile_OptimizeAndAssemble (c=c@entry=0x50b000075480, addNone=addNone@entry=1) at ../Python/compile.c:1369 #14 0x0000555556cfe44c in compiler_mod (c=c@entry=0x50b000075480, mod=mod@entry=0x5250000231e8) at ../Python/compile.c:825 --Type <RET> for more, q to quit, c to continue without paging-- #15 0x0000555556cfe4da in _PyAST_Compile (mod=mod@entry=0x5250000231e8, filename=filename@entry=0x50700011db30, pflags=pflags@entry=0x7ffff4727b40, optimize=optimize@entry=-1, arena=arena@entry=0x5080001299b0) at ../Python/compile.c:1382 #16 0x0000555556bf755c in builtin_compile_impl (module=module@entry=0x508000049f40, source=source@entry=0x5070001d8af0, filename=<optimized out>, mode=mode@entry=0x5070000459c8 "exec", flags=flags@entry=0, dont_inherit=dont_inherit@entry=0, optimize=<optimized out>, feature_version=<optimized out>) at ../Python/bltinmodule.c:868 #17 0x0000555556bf7e98 in builtin_compile (module=<optimized out>, args=<optimized out>, args@entry=0x529000005280, nargs=nargs@entry=3, kwnames=kwnames@entry=0x0) at ../Python/clinic/bltinmodule.c.h:363 #18 0x000055555692f626 in cfunction_vectorcall_FASTCALL_KEYWORDS (func=0x50800004a540, args=0x529000005280, nargsf=<optimized out>, kwnames=0x0) at ../Objects/methodobject.c:452 #19 0x00005555567fb2e6 in _PyObject_VectorcallTstate (tstate=0x55555867f8f8 <_PyRuntime+329752>, callable=callable@entry=0x50800004a540, args=args@entry=0x529000005280, nargsf=9223372036854775811, kwnames=kwnames@entry=0x0) at ../Include/internal/pycore_call.h:167 #20 0x00005555567fb42f in PyObject_Vectorcall (callable=callable@entry=0x50800004a540, args=args@entry=0x529000005280, nargsf=<optimized out>, kwnames=kwnames@entry=0x0) at ../Objects/call.c:327 #21 0x0000555556c21af5 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x55555867f8f8 <_PyRuntime+329752>, frame=frame@entry=0x529000005220, throwflag=throwflag@entry=0) at ../Python/generated_cases.c.h:1023 #22 0x0000555556c9d225 in _PyEval_EvalFrame (tstate=tstate@entry=0x55555867f8f8 <_PyRuntime+329752>, frame=frame@entry=0x529000005220, throwflag=throwflag@entry=0) at ../Include/internal/pycore_ceval.h:116 #23 0x0000555556c9d743 in _PyEval_Vector (tstate=tstate@entry=0x55555867f8f8 <_PyRuntime+329752>, func=func@entry=0x51000003d560, locals=locals@entry=0x50800009c340, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at ../Python/ceval.c:1921 #24 0x0000555556c9da3e in PyEval_EvalCode (co=co@entry=0x514000033450, globals=globals@entry=0x50800009c340, locals=locals@entry=0x50800009c340) at ../Python/ceval.c:660 #25 0x0000555556e22f41 in run_eval_code_obj (tstate=tstate@entry=0x55555867f8f8 <_PyRuntime+329752>, co=co@entry=0x514000033450, globals=globals@entry=0x50800009c340, locals=locals@entry=0x50800009c340) at ../Python/pythonrun.c:1338 #26 0x0000555556e23378 in run_mod (mod=mod@entry=0x5250000191e0, filename=filename@entry=0x50b000041080, globals=globals@entry=0x50800009c340, locals=locals@entry=0x50800009c340, flags=flags@entry=0x7ffff4927e30, arena=arena@entry=0x5080000c27b0, interactive_src=0x0, generate_new_source=0) at ../Python/pythonrun.c:1423 #27 0x0000555556e25e70 in pyrun_file (fp=fp@entry=0x51500000fa80, filename=filename@entry=0x50b000041080, start=start@entry=257, globals=globals@entry=0x50800009c340, locals=locals@entry=0x50800009c340, closeit=closeit@entry=1, flags=0x7ffff4927e30) at ../Python/pythonrun.c:1256 #28 0x0000555556e27d8b in _PyRun_SimpleFileObject (fp=fp@entry=0x51500000fa80, filename=filename@entry=0x50b000041080, closeit=closeit@entry=1, flags=flags@entry=0x7ffff4927e30) at ../Python/pythonrun.c:491 #29 0x0000555556e280de in _PyRun_AnyFileObject (fp=fp@entry=0x51500000fa80, filename=filename@entry=0x50b000041080, closeit=closeit@entry=1, flags=flags@entry=0x7ffff4927e30) at ../Python/pythonrun.c:78 #30 0x0000555556eb16f3 in pymain_run_file_obj (program_name=program_name@entry=0x50b000041130, filename=filename@entry=0x50b000041080, skip_source_first_line=<optimized out>) at ../Modules/main.c:410 #31 0x0000555556eb19cd in pymain_run_file (config=config@entry=0x55555864aa88 <_PyRuntime+113064>) at ../Modules/main.c:429 #32 0x0000555556eb4731 in pymain_run_python (exitcode=exitcode@entry=0x7ffff4640760) at ../Modules/main.c:697 #33 0x0000555556eb48f8 in Py_RunMain () at ../Modules/main.c:776 #34 0x0000555556eb4b0d in pymain_main (args=args@entry=0x7ffff470a0a0) at ../Modules/main.c:806 #35 0x0000555556eb4e92 in Py_BytesMain (argc=2, argv=0x7fffffffda78) at ../Modules/main.c:830 #36 0x0000555556590ba6 in main (argc=<optimized out>, argv=<optimized out>) at ../Programs/python.c:15 ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.14.0a4+ (heads/main-dirty:75f59bb6293, Jan 23 2025, 22:33:08) [GCC 13.3.0] <!-- gh-linked-prs --> ### Linked PRs * gh-130795 * gh-132243 * gh-132260 <!-- /gh-linked-prs -->
bc5233b6a5cdd8f77a4737ce317f94110869c082
8e260b384aad1910e12b68981cd8390919184d5d
python/cpython
python__cpython-130738
# Ensure `stdbool.h` is included after `Python.h` # Bug report Including `stdbool.h` before `Python.h` may cause build issues when using `zig cc`. See https://github.com/python/cpython/pull/130641 and https://github.com/python/cpython/pull/130641#issuecomment-2692299464. <!-- gh-linked-prs --> ### Linked PRs * gh-130738 * gh-130756 * gh-130757 <!-- /gh-linked-prs -->
214562ed4ddc248b007f718ed92ebcc0c3669611
051f0e5683fec3840fa7fc99723741dd2d701eae