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-130797
# `test_notify` multiprocessing test is flaky # Bug report Seen in https://github.com/python/cpython/actions/runs/13606907022/job/38039459160?pr=130732 ``` FAIL: test_notify (test.test_multiprocessing_spawn.test_threads.WithThreadsTestCondition.test_notify) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\a\cpython\cpython\Lib\test\_test_multiprocessing.py", line 1691, in test_notify self.assertReturnsIfImplemented(2, get_value, woken) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "D:\a\cpython\cpython\Lib\test\_test_multiprocessing.py", line 275, in assertReturnsIfImplemented return self.assertEqual(value, res) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^ AssertionError: 2 != 1 ``` <!-- gh-linked-prs --> ### Linked PRs * gh-130797 * gh-130802 * gh-130803 <!-- /gh-linked-prs -->
8a64a62002fa3cdc93cb4cfee315edb235cad8cb
d0eb01c9de9a455df36f885506314d8d00645c9f
python/cpython
python__cpython-130800
# `test_shutdown_default_executor_timeout` asyncio test is flaky # Bug report Seen in https://github.com/python/cpython/actions/runs/13606907022/job/38039459160?pr=130732 ``` FAIL: test_shutdown_default_executor_timeout (test.test_asyncio.test_base_events.BaseEventLoopTests.test_shutdown_default_executor_timeout) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\a\cpython\cpython\Lib\test\test_asyncio\test_base_events.py", line 246, in test_shutdown_default_executor_timeout with self.assertWarnsRegex(RuntimeWarning, ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ "The executor did not finishing joining"): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: RuntimeWarning not triggered ``` <!-- gh-linked-prs --> ### Linked PRs * gh-130800 * gh-130825 * gh-130826 <!-- /gh-linked-prs -->
6c48ed7d62c6ca0eb24935b0e612f9e4a1a3b1bc
3929af5e3a203291dc07b40c9c3515492e3ba7b4
python/cpython
python__cpython-130832
# [Windows] test_wmi: `test_wmi_query_error` test is flaky # Bug report Seen in https://github.com/python/cpython/actions/runs/13606431591/job/38038447105?pr=130724 on both the default and free threading builds: ``` ====================================================================== FAIL: test_wmi_query_error (test.test_wmi.WmiTests.test_wmi_query_error) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\a\cpython\cpython\Lib\test\test_wmi.py", line 50, in test_wmi_query_error self.fail("Expected OSError") ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ AssertionError: Expected OSError ---------------------------------------------------------------------- ``` ``` ====================================================================== FAIL: test_wmi_query_repeated_error (test.test_wmi.WmiTests.test_wmi_query_repeated_error) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\a\cpython\cpython\Lib\test\test_wmi.py", line 54, in test_wmi_query_repeated_error self.test_wmi_query_error() ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "D:\a\cpython\cpython\Lib\test\test_wmi.py", line 50, in test_wmi_query_error self.fail("Expected OSError") ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ AssertionError: Expected OSError ---------------------------------------------------------------------- ``` ``` ====================================================================== ERROR: test_wmi_query_repeated (test.test_wmi.WmiTests.test_wmi_query_repeated) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\a\cpython\cpython\Lib\test\test_wmi.py", line 40, in test_wmi_query_repeated self.test_wmi_query_os_version() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "D:\a\cpython\cpython\Lib\test\test_wmi.py", line 28, in test_wmi_query_os_version r = wmi_exec_query("SELECT Version FROM Win32_OperatingSystem").split("\0") ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\a\cpython\cpython\Lib\test\test_wmi.py", line 23, in wmi_exec_query return _wmi.exec_query(query) ~~~~~~~~~~~~~~~^^^^^^^ TimeoutError: [WinError 258] The wait operation timed out ---------------------------------------------------------------------- Ran 8 tests in 45.543s FAILED (errors=1, skipped=1) ``` In these cases the tests succeeded when retried. <!-- gh-linked-prs --> ### Linked PRs * gh-130832 * gh-130839 * gh-130840 * gh-134313 * gh-134396 * gh-134397 <!-- /gh-linked-prs -->
f67ff9e82071b21c1960401aed4844b00b5bfb53
1d251b8339a34a54e5d82d912d90bc0ca96e8757
python/cpython
python__cpython-130712
# Undocumented public C-API `PyBaseObject_Type` # Documentation `PyBaseObject_Type` is in the limited API and not documented. <!-- gh-linked-prs --> ### Linked PRs * gh-130712 * gh-130792 * gh-130793 <!-- /gh-linked-prs -->
b3c18bfd828ba90b9c712da74095c4a052887655
4f14b7e30c0243e81407a34968495301e829a033
python/cpython
python__cpython-130708
# Optimize reference counting overhead of `LOAD_FAST` variants # Feature or enhancement ### Proposal: `LOAD_FAST` and its super instruction form are the most frequently executed bytecode instructions in most Python programs (they represent ~20% of dynamic instruction frequency on the benchmark suite). While they are very cheap (they're just an incref and a push to the stack), they are not free. If we can prove that the reference in the frame outlives the reference that is loaded on the stack we can use a cheaper variant of `LOAD_FAST` that loads an appropriately tagged borrowed reference onto the operand stack, thereby avoiding the incref/decref. ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: https://github.com/faster-cpython/ideas/issues/700 <!-- gh-linked-prs --> ### Linked PRs * gh-130708 <!-- /gh-linked-prs -->
053c285f6b41f92fbdd1d4ff0c959cceefacd7cd
e9556e100452ed5a92fcf0e333ab75b0da29cf5b
python/cpython
python__cpython-130906
# JIT build crashes on x86_64-linux with LLVM 18 # Bug report ### Bug description: I'm trying to build CPython 3.13.2 with JIT supported (`--enable-experimental-jit=yes-off`), but the build process crashes after reporting like this: ```text python3> | Traceback (most recent call last): python3> | File "/build/Python-3.13.2/Tools/jit/_targets.py", line 181, in _compile python3> | return await self._parse(o) python3> | ^^^^^^^^^^^^^^^^^^^^ python3> | File "/build/Python-3.13.2/Tools/jit/_targets.py", line 89, in _parse python3> | self._handle_section(wrapped_section["Section"], group) python3> | File "/build/Python-3.13.2/Tools/jit/_targets.py", line 330, in _handle_section python3> | value, base = group.symbols[section["Info"]] python3> | ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ python3> | KeyError: 5 ``` I've tracked the build process and found that the `_parse` routine in `Tools/_targets.py` almost fails for all the object files produced by the `_compile` process. When handling a ELF section of type `SHT_PROGBITS`, if `SHF_ALLOC` is not included in its flags, then the symbol tables of the stencil group will not be updated. Then if a later section refers to the symbol, a `KeyError` occurs. For example, an object file (_NOP.o) like this: ```json [ { "Section": { "Index": 5, "Name": { "Name": ".debug_info", "Value": 108 }, "Type": { "Name": "SHT_PROGBITS", "Value": 1 }, "Flags": { "Value": 2048, "Flags": [{ "Name": "SHF_COMPRESSED", "Value": 2048 }] }, "Address": 0, "Offset": 463, "Size": 29486, "Link": 0, "Info": 0 // ... }, { "Section": { "Index": 6, "Name": { "Name": ".rela.debug_info", "Value": 103 }, "Type": { "Name": "SHT_RELA", "Value": 4 }, "Flags": { "Value": 64, "Flags": [{ "Name": "SHF_INFO_LINK", "Value": 64 }] }, "Address": 0, "Offset": 44968, "Size": 96, "Link": 20, "Info": 5 // ... } ``` When handling the 5th section, L349 is not executed: https://github.com/python/cpython/blob/4f8bb3947cfbc20f970ff9d9531e1132a9e95396/Tools/jit/_targets.py#L340-L357 Then when handling the 6th section, L330 will try to index `group.symbols[5]`: https://github.com/python/cpython/blob/4f8bb3947cfbc20f970ff9d9531e1132a9e95396/Tools/jit/_targets.py#L327-L339 where the error occurs. I'm not sure whether it's because of the version of LLVM (18.1.8) I'm using. ### CPython versions tested on: 3.13.2 ### Operating systems tested on: GNU/Linux ### Build Toolchains - Python 3.12.4 - LLVM 18.1.8 <!-- gh-linked-prs --> ### Linked PRs * gh-130906 * gh-131749 <!-- /gh-linked-prs -->
a26a301f8b09c1825b288fc8649f8174576361f4
488174dc68f90217fd43aa95d87441cc6bad6a29
python/cpython
python__cpython-130676
# test_calendar and test_pdb always fail in non-English locale Example of the `test_calendar` output for locale uk_UA.UTF-8: ```pytb ====================================================================== FAIL: test_option_encoding (test.test_calendar.CommandLineTestCase.test_option_encoding) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_calendar.py", line 1035, in test_option_encoding self.assertEqual(output, result_2004_text.encode('utf-16-le')) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: b' \x[224 chars] \x00 \x00A\x04V\x04G\x04=\x04O\x04 \x00 \x00 [10163 chars]\x00' != b' \x[224 chars] \x00J\x00a\x00n\x00u\x00a\x00r\x00y\x00 \x00 [10163 chars]\x00' ====================================================================== FAIL: test_option_lines (test.test_calendar.CommandLineTestCase.test_option_lines) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_calendar.py", line 1074, in test_option_lines self.assertIn(conv('December\n\nMo Tu We'), output) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: b'December\n\nMo Tu We' not found in b' 2004\n\n\n\n \xd1\x81\xd1\x96\xd1\x87\xd0\xbd\xd1\x8f \xd0\xbb\xd1\x8e\xd1\x82\xd0\xbe\xd0\xb3\xd0\xbe \xd0\xb1\xd0\xb5\xd1\x80\xd0\xb5\xd0\xb7\xd0\xbd\xd1\x8f\n\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n\n 1 2 3 4 1 1 2 3 4 5 6 7\n\n 5 6 7 8 9 10 11 2 3 4 5 6 7 8 8 9 10 11 12 13 14\n\n12 13 14 15 16 17 18 9 10 11 12 13 14 15 15 16 17 18 19 20 21\n\n19 20 21 22 23 24 25 16 17 18 19 20 21 22 22 23 24 25 26 27 28\n\n26 27 28 29 30 31 23 24 25 26 27 28 29 29 30 31\n\n\n\n \xd0\xba\xd0\xb2\xd1\x96\xd1\x82\xd0\xbd\xd1\x8f \xd1\x82\xd1\x80\xd0\xb0\xd0\xb2\xd0\xbd\xd1\x8f \xd1\x87\xd0\xb5\xd1\x80\xd0\xb2\xd0\xbd\xd1\x8f\n\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n\n 1 2 3 4 1 2 1 2 3 4 5 6\n\n 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13\n\n12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20\n\n19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27\n\n26 27 28 29 30 24 25 26 27 28 29 30 28 29 30\n\n 31\n\n\n\n \xd0\xbb\xd0\xb8\xd0\xbf\xd0\xbd\xd1\x8f \xd1\x81\xd0\xb5\xd1\x80\xd0\xbf\xd0\xbd\xd1\x8f \xd0\xb2\xd0\xb5\xd1\x80\xd0\xb5\xd1\x81\xd0\xbd\xd1\x8f\n\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n\n 1 2 3 4 1 1 2 3 4 5\n\n 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12\n\n12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19\n\n19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26\n\n26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30\n\n 30 31\n\n\n\n \xd0\xb6\xd0\xbe\xd0\xb2\xd1\x82\xd0\xbd\xd1\x8f \xd0\xbb\xd0\xb8\xd1\x81\xd1\x82\xd0\xbe\xd0\xbf\xd0\xb0\xd0\xb4\xd0\xb0 \xd0\xb3\xd1\x80\xd1\x83\xd0\xb4\xd0\xbd\xd1\x8f\n\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n\n 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5\n\n 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12\n\n11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19\n\n18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26\n\n25 26 27 28 29 30 31 29 30 27 28 29 30 31\n\n' ====================================================================== FAIL: test_option_months (test.test_calendar.CommandLineTestCase.test_option_months) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_calendar.py", line 1090, in test_option_months self.assertIn(conv('\nMo Tu We Th Fr Sa Su\n'), output) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: b'\nMo Tu We Th Fr Sa Su\n' not found in b' 2004\n\n \xd1\x81\xd1\x96\xd1\x87\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4\n 5 6 7 8 9 10 11\n12 13 14 15 16 17 18\n19 20 21 22 23 24 25\n26 27 28 29 30 31\n\n \xd0\xbb\xd1\x8e\xd1\x82\xd0\xbe\xd0\xb3\xd0\xbe\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1\n 2 3 4 5 6 7 8\n 9 10 11 12 13 14 15\n16 17 18 19 20 21 22\n23 24 25 26 27 28 29\n\n \xd0\xb1\xd0\xb5\xd1\x80\xd0\xb5\xd0\xb7\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 5 6 7\n 8 9 10 11 12 13 14\n15 16 17 18 19 20 21\n22 23 24 25 26 27 28\n29 30 31\n\n \xd0\xba\xd0\xb2\xd1\x96\xd1\x82\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4\n 5 6 7 8 9 10 11\n12 13 14 15 16 17 18\n19 20 21 22 23 24 25\n26 27 28 29 30\n\n \xd1\x82\xd1\x80\xd0\xb0\xd0\xb2\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2\n 3 4 5 6 7 8 9\n10 11 12 13 14 15 16\n17 18 19 20 21 22 23\n24 25 26 27 28 29 30\n31\n\n \xd1\x87\xd0\xb5\xd1\x80\xd0\xb2\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 5 6\n 7 8 9 10 11 12 13\n14 15 16 17 18 19 20\n21 22 23 24 25 26 27\n28 29 30\n\n \xd0\xbb\xd0\xb8\xd0\xbf\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4\n 5 6 7 8 9 10 11\n12 13 14 15 16 17 18\n19 20 21 22 23 24 25\n26 27 28 29 30 31\n\n \xd1\x81\xd0\xb5\xd1\x80\xd0\xbf\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1\n 2 3 4 5 6 7 8\n 9 10 11 12 13 14 15\n16 17 18 19 20 21 22\n23 24 25 26 27 28 29\n30 31\n\n \xd0\xb2\xd0\xb5\xd1\x80\xd0\xb5\xd1\x81\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 5\n 6 7 8 9 10 11 12\n13 14 15 16 17 18 19\n20 21 22 23 24 25 26\n27 28 29 30\n\n \xd0\xb6\xd0\xbe\xd0\xb2\xd1\x82\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3\n 4 5 6 7 8 9 10\n11 12 13 14 15 16 17\n18 19 20 21 22 23 24\n25 26 27 28 29 30 31\n\n \xd0\xbb\xd0\xb8\xd1\x81\xd1\x82\xd0\xbe\xd0\xbf\xd0\xb0\xd0\xb4\xd0\xb0\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 5 6 7\n 8 9 10 11 12 13 14\n15 16 17 18 19 20 21\n22 23 24 25 26 27 28\n29 30\n\n \xd0\xb3\xd1\x80\xd1\x83\xd0\xb4\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 5\n 6 7 8 9 10 11 12\n13 14 15 16 17 18 19\n20 21 22 23 24 25 26\n27 28 29 30 31\n' ====================================================================== FAIL: test_option_spacing (test.test_calendar.CommandLineTestCase.test_option_spacing) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_calendar.py", line 1082, in test_option_spacing self.assertIn(b'Su Mo', output) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: b'Su Mo' not found in b' 2004\n\n \xd1\x81\xd1\x96\xd1\x87\xd0\xbd\xd1\x8f \xd0\xbb\xd1\x8e\xd1\x82\xd0\xbe\xd0\xb3\xd0\xbe \xd0\xb1\xd0\xb5\xd1\x80\xd0\xb5\xd0\xb7\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 1 1 2 3 4 5 6 7\n 5 6 7 8 9 10 11 2 3 4 5 6 7 8 8 9 10 11 12 13 14\n12 13 14 15 16 17 18 9 10 11 12 13 14 15 15 16 17 18 19 20 21\n19 20 21 22 23 24 25 16 17 18 19 20 21 22 22 23 24 25 26 27 28\n26 27 28 29 30 31 23 24 25 26 27 28 29 29 30 31\n\n \xd0\xba\xd0\xb2\xd1\x96\xd1\x82\xd0\xbd\xd1\x8f \xd1\x82\xd1\x80\xd0\xb0\xd0\xb2\xd0\xbd\xd1\x8f \xd1\x87\xd0\xb5\xd1\x80\xd0\xb2\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 1 2 1 2 3 4 5 6\n 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13\n12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20\n19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27\n26 27 28 29 30 24 25 26 27 28 29 30 28 29 30\n 31\n\n \xd0\xbb\xd0\xb8\xd0\xbf\xd0\xbd\xd1\x8f \xd1\x81\xd0\xb5\xd1\x80\xd0\xbf\xd0\xbd\xd1\x8f \xd0\xb2\xd0\xb5\xd1\x80\xd0\xb5\xd1\x81\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 1 1 2 3 4 5\n 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12\n12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19\n19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26\n26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30\n 30 31\n\n \xd0\xb6\xd0\xbe\xd0\xb2\xd1\x82\xd0\xbd\xd1\x8f \xd0\xbb\xd0\xb8\xd1\x81\xd1\x82\xd0\xbe\xd0\xbf\xd0\xb0\xd0\xb4\xd0\xb0 \xd0\xb3\xd1\x80\xd1\x83\xd0\xb4\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5\n 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12\n11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19\n18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26\n25 26 27 28 29 30 31 29 30 27 28 29 30 31\n' ====================================================================== FAIL: test_option_type (test.test_calendar.CommandLineTestCase.test_option_type) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_calendar.py", line 1098, in test_option_type self.assertEqual(output, conv(result_2004_text)) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: b' [40 chars] \xd1\x81\xd1\x96\xd1\x87\xd0\xbd\xd1\x8f[3724 chars]31\n' != b' [40 chars] January February [2023 chars]31\n' ====================================================================== FAIL: test_option_width (test.test_calendar.CommandLineTestCase.test_option_width) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_calendar.py", line 1066, in test_option_width self.assertIn(b'Mon Tue Wed Thu Fri Sat Sun', output) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: b'Mon Tue Wed Thu Fri Sat Sun' not found in b' 2004\n\n \xd1\x81\xd1\x96\xd1\x87\xd0\xbd\xd1\x8f \xd0\xbb\xd1\x8e\xd1\x82\xd0\xbe\xd0\xb3\xd0\xbe \xd0\xb1\xd0\xb5\xd1\x80\xd0\xb5\xd0\xb7\xd0\xbd\xd1\x8f\n \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 1 1 2 3 4 5 6 7\n 5 6 7 8 9 10 11 2 3 4 5 6 7 8 8 9 10 11 12 13 14\n 12 13 14 15 16 17 18 9 10 11 12 13 14 15 15 16 17 18 19 20 21\n 19 20 21 22 23 24 25 16 17 18 19 20 21 22 22 23 24 25 26 27 28\n 26 27 28 29 30 31 23 24 25 26 27 28 29 29 30 31\n\n \xd0\xba\xd0\xb2\xd1\x96\xd1\x82\xd0\xbd\xd1\x8f \xd1\x82\xd1\x80\xd0\xb0\xd0\xb2\xd0\xbd\xd1\x8f \xd1\x87\xd0\xb5\xd1\x80\xd0\xb2\xd0\xbd\xd1\x8f\n \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 1 2 1 2 3 4 5 6\n 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13\n 12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20\n 19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27\n 26 27 28 29 30 24 25 26 27 28 29 30 28 29 30\n 31\n\n \xd0\xbb\xd0\xb8\xd0\xbf\xd0\xbd\xd1\x8f \xd1\x81\xd0\xb5\xd1\x80\xd0\xbf\xd0\xbd\xd1\x8f \xd0\xb2\xd0\xb5\xd1\x80\xd0\xb5\xd1\x81\xd0\xbd\xd1\x8f\n \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 1 1 2 3 4 5\n 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12\n 12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19\n 19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26\n 26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30\n 30 31\n\n \xd0\xb6\xd0\xbe\xd0\xb2\xd1\x82\xd0\xbd\xd1\x8f \xd0\xbb\xd0\xb8\xd1\x81\xd1\x82\xd0\xbe\xd0\xbf\xd0\xb0\xd0\xb4\xd0\xb0 \xd0\xb3\xd1\x80\xd1\x83\xd0\xb4\xd0\xbd\xd1\x8f\n \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5\n 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12\n 11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19\n 18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26\n 25 26 27 28 29 30 31 29 30 27 28 29 30 31\n' ====================================================================== FAIL: test_output_current_year (test.test_calendar.CommandLineTestCase.test_output_current_year) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_calendar.py", line 1017, in test_output_current_year self.assertIn(b'January', output) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ AssertionError: b'January' not found in b' 2025\n\n \xd1\x81\xd1\x96\xd1\x87\xd0\xbd\xd1\x8f \xd0\xbb\xd1\x8e\xd1\x82\xd0\xbe\xd0\xb3\xd0\xbe \xd0\xb1\xd0\xb5\xd1\x80\xd0\xb5\xd0\xb7\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 5 1 2 1 2\n 6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9\n13 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16\n20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23\n27 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30\n 31\n\n \xd0\xba\xd0\xb2\xd1\x96\xd1\x82\xd0\xbd\xd1\x8f \xd1\x82\xd1\x80\xd0\xb0\xd0\xb2\xd0\xbd\xd1\x8f \xd1\x87\xd0\xb5\xd1\x80\xd0\xb2\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 5 6 1 2 3 4 1\n 7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8\n14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15\n21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22\n28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29\n 30\n\n \xd0\xbb\xd0\xb8\xd0\xbf\xd0\xbd\xd1\x8f \xd1\x81\xd0\xb5\xd1\x80\xd0\xbf\xd0\xbd\xd1\x8f \xd0\xb2\xd0\xb5\xd1\x80\xd0\xb5\xd1\x81\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7\n 7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14\n14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21\n21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28\n28 29 30 31 25 26 27 28 29 30 31 29 30\n\n \xd0\xb6\xd0\xbe\xd0\xb2\xd1\x82\xd0\xbd\xd1\x8f \xd0\xbb\xd0\xb8\xd1\x81\xd1\x82\xd0\xbe\xd0\xbf\xd0\xb0\xd0\xb4\xd0\xb0 \xd0\xb3\xd1\x80\xd1\x83\xd0\xb4\xd0\xbd\xd1\x8f\n\xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbd \xd0\xb2\xd1\x82 \xd1\x81\xd1\x80 \xd1\x87\xd1\x82 \xd0\xbf\xd1\x82 \xd1\x81\xd0\xb1 \xd0\xbd\xd0\xb4\n 1 2 3 4 5 1 2 1 2 3 4 5 6 7\n 6 7 8 9 10 11 12 3 4 5 6 7 8 9 8 9 10 11 12 13 14\n13 14 15 16 17 18 19 10 11 12 13 14 15 16 15 16 17 18 19 20 21\n20 21 22 23 24 25 26 17 18 19 20 21 22 23 22 23 24 25 26 27 28\n27 28 29 30 31 24 25 26 27 28 29 30 29 30 31\n' ====================================================================== FAIL: test_output_month (test.test_calendar.CommandLineTestCase.test_output_month) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_calendar.py", line 1028, in test_output_month self.assertEqual(output, conv(result_2004_01_text)) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: b' \xd1\x81\xd1\x96\xd1\x87\xd0\xbd\xd1\x8f[230 chars]31\n' != b' January 2004\nMo Tu We Th Fr Sa Su\n [98 chars]31\n' ====================================================================== FAIL: test_output_year (test.test_calendar.CommandLineTestCase.test_output_year) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_calendar.py", line 1023, in test_output_year self.assertEqual(output, conv(result_2004_text)) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: b' [40 chars] \xd1\x81\xd1\x96\xd1\x87\xd0\xbd\xd1\x8f[3724 chars]31\n' != b' [40 chars] January February [2023 chars]31\n' ---------------------------------------------------------------------- ``` `test_pdb` also fails, because it uses the `calendar` module: ```pytb ====================================================================== FAIL: test_run_module_with_args (test.test_pdb.PdbTestCase.test_run_module_with_args) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_pdb.py", line 3696, in test_run_module_with_args self.assertIn("December", stdout) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ AssertionError: 'December' not found in '> /home/serhiy/py/cpython/Lib/calendar.py(1)<module>()\n-> """Calendar printing functions\n(Pdb) (Pdb) 1\n\n січня лютого березня\nпн вт ср чт пт сб нд пн вт ср чт пт сб нд пн вт ср чт пт сб нд\n 1 2 3 4 5 6 7 1 2 3 4 1 2 3 4\n 8 9 10 11 12 13 14 5 6 7 8 9 10 11 5 6 7 8 9 10 11\n15 16 17 18 19 20 21 12 13 14 15 16 17 18 12 13 14 15 16 17 18\n22 23 24 25 26 27 28 19 20 21 22 23 24 25 19 20 21 22 23 24 25\n29 30 31 26 27 28 26 27 28 29 30 31\n\n квітня травня червня\nпн вт ср чт пт сб нд пн вт ср чт пт сб нд пн вт ср чт пт сб нд\n 1 1 2 3 4 5 6 1 2 3\n 2 3 4 5 6 7 8 7 8 9 10 11 12 13 4 5 6 7 8 9 10\n 9 10 11 12 13 14 15 14 15 16 17 18 19 20 11 12 13 14 15 16 17\n16 17 18 19 20 21 22 21 22 23 24 25 26 27 18 19 20 21 22 23 24\n23 24 25 26 27 28 29 28 29 30 31 25 26 27 28 29 30\n30\n\n липня серпня вересня\nпн вт ср чт пт сб нд пн вт ср чт пт сб нд пн вт ср чт пт сб нд\n 1 1 2 3 4 5 1 2\n 2 3 4 5 6 7 8 6 7 8 9 10 11 12 3 4 5 6 7 8 9\n 9 10 11 12 13 14 15 13 14 15 16 17 18 19 10 11 12 13 14 15 16\n16 17 18 19 20 21 22 20 21 22 23 24 25 26 17 18 19 20 21 22 23\n23 24 25 26 27 28 29 27 28 29 30 31 24 25 26 27 28 29 30\n30 31\n\n жовтня листопада грудня\nпн вт ср чт пт сб нд пн вт ср чт пт сб нд пн вт ср чт пт сб нд\n 1 2 3 4 5 6 7 1 2 3 4 1 2\n 8 9 10 11 12 13 14 5 6 7 8 9 10 11 3 4 5 6 7 8 9\n15 16 17 18 19 20 21 12 13 14 15 16 17 18 10 11 12 13 14 15 16\n22 23 24 25 26 27 28 19 20 21 22 23 24 25 17 18 19 20 21 22 23\n29 30 31 26 27 28 29 30 24 25 26 27 28 29 30\n 31\nThe program finished and will be restarted\n> /home/serhiy/py/cpython/Lib/calendar.py(1)<module>()\n-> """Calendar printing functions\n(Pdb) 1\n\n січня лютого березня\nпн вт ср чт пт сб нд пн вт ср чт пт сб нд пн вт ср чт пт сб нд\n 1 2 3 4 5 6 7 1 2 3 4 1 2 3 4\n 8 9 10 11 12 13 14 5 6 7 8 9 10 11 5 6 7 8 9 10 11\n15 16 17 18 19 20 21 12 13 14 15 16 17 18 12 13 14 15 16 17 18\n22 23 24 25 26 27 28 19 20 21 22 23 24 25 19 20 21 22 23 24 25\n29 30 31 26 27 28 26 27 28 29 30 31\n\n квітня травня червня\nпн вт ср чт пт сб нд пн вт ср чт пт сб нд пн вт ср чт пт сб нд\n 1 1 2 3 4 5 6 1 2 3\n 2 3 4 5 6 7 8 7 8 9 10 11 12 13 4 5 6 7 8 9 10\n 9 10 11 12 13 14 15 14 15 16 17 18 19 20 11 12 13 14 15 16 17\n16 17 18 19 20 21 22 21 22 23 24 25 26 27 18 19 20 21 22 23 24\n23 24 25 26 27 28 29 28 29 30 31 25 26 27 28 29 30\n30\n\n липня серпня вересня\nпн вт ср чт пт сб нд пн вт ср чт пт сб нд пн вт ср чт пт сб нд\n 1 1 2 3 4 5 1 2\n 2 3 4 5 6 7 8 6 7 8 9 10 11 12 3 4 5 6 7 8 9\n 9 10 11 12 13 14 15 13 14 15 16 17 18 19 10 11 12 13 14 15 16\n16 17 18 19 20 21 22 20 21 22 23 24 25 26 17 18 19 20 21 22 23\n23 24 25 26 27 28 29 27 28 29 30 31 24 25 26 27 28 29 30\n30 31\n\n жовтня листопада грудня\nпн вт ср чт пт сб нд пн вт ср чт пт сб нд пн вт ср чт пт сб нд\n 1 2 3 4 5 6 7 1 2 3 4 1 2\n 8 9 10 11 12 13 14 5 6 7 8 9 10 11 3 4 5 6 7 8 9\n15 16 17 18 19 20 21 12 13 14 15 16 17 18 10 11 12 13 14 15 16\n22 23 24 25 26 27 28 19 20 21 22 23 24 25 17 18 19 20 21 22 23\n29 30 31 26 27 28 29 30 24 25 26 27 28 29 30\n 31\nThe program finished and will be restarted\n> /home/serhiy/py/cpython/Lib/calendar.py(1)<module>()\n-> """Calendar printing functions\n(Pdb) \n' ---------------------------------------------------------------------- ``` This is caused by #128317. Reverting that change fixes tests. cc @hugovk <!-- gh-linked-prs --> ### Linked PRs * gh-130676 <!-- /gh-linked-prs -->
c1b4a6bd6151d0f777c5256e1d5e2304717932e6
e21863ce78b17ab9fc98df08681d89e57c275a60
python/cpython
python__cpython-130663
# format(Fraction(1, 3), '.016f') raises ValueError # Bug report ### Bug description: c.f. ```python >>> format(float(Fraction(1, 3)), '.016f') '0.3333333333333333' ``` Looking on [docs](https://docs.python.org/3.14/library/string.html#format-specification-mini-language), I think that float formatting better conforms to the specification. Similar issue is valid for the width: ```py >>> format(float(Fraction(1, 3)), '0030.016f') '0000000000000.3333333333333333' >>> format(Fraction(1, 3), '0030.016f') Traceback (most recent call last): File "<python-input-3>", line 1, in <module> format(Fraction(1, 3), '0030.016f') ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.13/fractions.py", line 577, in __format__ raise ValueError( ...<2 lines>... ) ValueError: Invalid format specifier '0030.016f' for object of type 'Fraction' ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130663 * gh-130717 * gh-132549 * gh-135026 * gh-136361 * gh-136362 <!-- /gh-linked-prs -->
5bc2d99126e40cb727a249939a4f905a51e8c920
baccfdb3d4d004cfb5308674e5e6ea6e598abcd7
python/cpython
python__cpython-130661
# sys.ps1 and sys.ps2 should be reverted after code.interact # Bug report ### Bug description: Our [documentation](https://docs.python.org/3/library/sys.html#sys.ps1) clearly states that `sys.ps1` and `sys.ps2` are only defined when the interpreter is in interactive mode. `code.interact` brings the interpreter to interactive mode, but after the function the interpreter is not in that mode anymore. Therefore, we should not keep `sys.ps1` and `sys.ps2` because that could mislead programs to think the interpreter is still in interactive mode. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130661 * gh-130852 <!-- /gh-linked-prs -->
fdcbc29f26448f47201ec40fcf3b6405631c85d3
54965f3fb25b381995a73b09d928c344bd2b86bd
python/cpython
python__cpython-132323
# Add colour to `argparse` help # Feature or enhancement In Python 3.13 we added colour output to the new REPL, `traceback` and `doctest`, and in 3.14 to `unittest`, `test.regrtest` and `calendar`, that can also be controlled with the `PYTHON_COLORS`, `NO_COLOR` and `FORCE_COLOR` environment variables: * https://docs.python.org/3.14/whatsnew/3.14.html#unittest * https://docs.python.org/3.14/using/cmdline.html#using-on-controlling-color Let's add colour to `argparse` help output. ## Survey First, here's a survey of some other CLIs that use colour: <details> <summary>Survey</summary> <table> <tr> <th colspan=2>uv <tr> <td> <img width="868" alt="Image" src="https://github.com/user-attachments/assets/31869566-6580-4035-b1f4-d5695b77cfb1" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/eea6349f-9590-4d2e-8cbe-9c0f27784cac" /> <tr> <th colspan=2>cargo <tr> <td><img width="864" alt="Image" src="https://github.com/user-attachments/assets/3b6834c1-ca9d-4c97-a8c5-e9af660a8144" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/b4722fca-1610-407e-8672-604e3de2baf5" /> <tr> <th colspan=2>composer <tr> <td><img width="864" alt="Image" src="https://github.com/user-attachments/assets/ad691d30-918e-4f88-8ae0-ca5fc2bbd7d6" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/fcb522cc-b6a8-47c4-b784-d121b7acff3e" /> <tr> <th colspan=2>ruff <tr> <td><img width="864" alt="Image" src="https://github.com/user-attachments/assets/42a962c3-33d9-4fa1-aa35-1ba5a55f650a" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/89f997ee-0a18-49f5-9039-1a5634503d90" /> <tr> <th colspan=2>lsd <tr> <td><img width="868" alt="Image" src="https://github.com/user-attachments/assets/03ad0675-1845-43aa-8802-fb6f3edf6d99" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/96b8b582-d40d-4a4e-be51-a04abb15c357" /> <tr> <th colspan=2>fd <tr> <td><img width="868" alt="Image" src="https://github.com/user-attachments/assets/cd5caa47-fbda-47f8-841b-c3386534e8e4" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/c4eac0cf-b46d-478f-8604-86d666109e17" /> See also: bat, hyperfine, oxipng, zizmor <tr> <th colspan=2>gh <tr> <td><img width="868" alt="Image" src="https://github.com/user-attachments/assets/10be9e0e-3712-4ae5-98c5-7b2dcfe91908" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/2ef5971b-c322-440c-8179-08cce3b78b76" /> <tr> <th colspan=2>rich-cli <tr> <td><img width="864" alt="Image" src="https://github.com/user-attachments/assets/4e7dae32-2992-419f-9ddc-92ae735ec3b9" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/abd1bebe-2dcf-4299-9295-de8da11a2500" /> <tr> <th colspan=2>typer <tr> <td><img width="864" alt="Image" src="https://github.com/user-attachments/assets/e32d0e16-8e2b-4597-97f2-43d9cdbd482f" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/135643a7-7a1a-4786-ab96-3a2d69393b27" /> </table> </details> These fall into four groups: * uv/cargo: green + cyan * composer: yellow + green * ruff/lsd/fd/gh: only bold * typer/rich-cli: green + cyan + yellow ## Prototypes I've made prototypes of two of these (uv/cargo style, typer/rich-cli style), and another with blue + magenta similar to the 3.13 REPL/traceback. <details> <summary>Prototypes</summary> <table> <tr> <th colspan=2>main <tr> <td><img width="864" alt="Image" src="https://github.com/user-attachments/assets/20be44cc-ae36-49d1-9911-3b4a0d6ddee6" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/35bfe5e9-5985-4db1-bfe4-a06f0bcf999e" /> <tr> <th colspan=2>uv/cargo style <tr> <td><img width="864" alt="Image" src="https://github.com/user-attachments/assets/21e21ab2-3e22-46ae-a10a-dd3dcc6c194d" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/e896f6e0-7112-482a-adba-21f1fdaa6dc1" /> <tr> <th colspan=2>typer/rich-cli style <tr> <td><img width="864" alt="Image" src="https://github.com/user-attachments/assets/a43c721b-0ad0-4087-b241-14bf86c96c9e" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/da4408e4-76c2-42c3-8fff-f1270c701d10" /> <tr> <th colspan=2>REPL style <tr> <td><img width="864" alt="Image" src="https://github.com/user-attachments/assets/3feb9a82-dfa8-4d29-8613-713db857bd00" /> <td><img width="871" alt="Image" src="https://github.com/user-attachments/assets/ab5cdf6a-47a3-413b-bdf1-2dc885dc4c9a" /> </table> </details> I think I prefer the typer/rich-cli style: the extra colour makes it easier to pick out the (green) short options from the (cyan) long options, and from their (green) arguments. And it should also be somewhat familiar to Python users who have used typer-based CLIs. <!-- gh-linked-prs --> ### Linked PRs * gh-132323 * gh-133380 * gh-136809 * gh-136886 <!-- /gh-linked-prs -->
4701ff92d747002d04b67688c7a581b1952773ac
ba16ba3a18e86e094bcd215892b49fb08c74ec0a
python/cpython
python__cpython-130646
# poplib.py: Missing integer parsing validation causes client crash on invalid server response # Crash report ### What happened? In [poplib.py at line 229](https://github.com/python/cpython/blob/8ba0d7bbc295781bf27902380521db97a272c442/Lib/poplib.py#L229) the code attempts to convert a server response to an integer without first verifying that the response is numeric. If the server returns a non-numeric response, the int() conversion fails causing the client to crash. ### CPython versions tested on: 3.12 ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130646 * gh-130763 * gh-130764 <!-- /gh-linked-prs -->
a42168d316f0c9a4fc5658dab87682dc19054efb
990ad272f66fe6a50087ad044725bb0f9f8e181d
python/cpython
python__cpython-130632
# Make join_header_words() more similar to the original Currently `http.cookiejar.join_header_words()` uses `re.search(r"^\w+$", v)` to check whether the value can be represented as a token, unquoted. There are some red flags here: 1. `\w` looks arbitrary. And it is. The original Perl implementation (it is now in [HTTP::Headers::Util](https://metacpan.org/pod/HTTP::Headers::Util)) uses a set of characters documented in `the split_header_words()` docstring. On one side, it allows more characters (like "." or "-") be unquoted, on other hand, it requires quoting non-ASCII letters and digits. 2. `$` matches not only the end of the string, but also a position just before `\n`. So this pattern does not work for value containing `\n`. I do not know whether such values are supported at higher level, but currently that code is prone to header injection. 3. Using `search()` with anchors at both ends for testing the whole string is very outdated, this patterns precedes the current `re` module. First, `match()` was added to testing the match from beginning, and later `fullmatch()` was added for testing the whole string. <!-- gh-linked-prs --> ### Linked PRs * gh-130632 * gh-132303 <!-- /gh-linked-prs -->
7ebbd271444d89218870169624921b795a717470
16dcb576f7623e19f22be631bbc0e565335da969
python/cpython
python__cpython-130638
# `UnicodeDecodeError` or `SystemError` when using `f-string` with `lambda` and non-ASCII characters # Bug report ### Bug description: When using an `f-string` in combination with `lambda` functions that return non-ASCII characters, either a `UnicodeDecodeError` or a `SystemError` is raised, depending on the specific modification made to the code. These errors do not occur consistently, but rather vary based on how the lambdas and string content are altered. ### Steps to Reproduce ```python def test1(foo, bar): return "" def test2(): return f"{test1( foo=lambda: '、、、、、、、、、、、、、、、、、', bar=lambda: 'abcdefghijklmnopqrstuvwxyz 123456789 123456789', )}" ``` Run the code with `python <file.py>`, which triggers the following error: ``` UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 28-29: unexpected end of data ``` ### Expected Behavior The code should execute without raising any errors. ### Actual Behavior The following behaviors are observed when making the specified modifications. Each of these cases is independent: 1. **Removing one `、` character** from the first string (`foo`): No error. 2. **Removing all `、` characters** from the first string: `SystemError: Negative size passed to PyUnicode_New`. 3. **Removing `foo=`** (i.e., not passing `foo` by keyword): No error. 4. **Removing `lambda: `** (i.e., making **either** argument or **both** into a `str` type instead of a `Callable[[], str]`): No error. 5. **Removing any character** from the second string (`bar`): No error. ### Other Relevant Information The bug does **not** reproduce in Python 3.13.1, but it **does** reproduce in Python 3.13.2 and 3.12.9. ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130638 * gh-130642 * gh-130644 <!-- /gh-linked-prs -->
e06bebb87e1b33f7251196e1ddb566f528c3fc98
b26286ca49d87ad8491e411f7b0283b0f15ad5be
python/cpython
python__cpython-130634
# build failed on DragonFlyBSD-6.4 # Bug report ### Bug description: ``` 2025-02-27T04:16:40.9317730Z /usr/bin/cc -pthread -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -I/root/.xbuilder/run/1051/auxroot/include -fPIC -fno-common -Os -I/root/.xbuilder/run/1051/auxroot/include -fPIC -fno-common -Os -g -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 -I/root/.xbuilder/run/1051/auxroot/include -I/root/.xbuilder/run/1051/auxroot/include/tirpc -I/root/.xbuilder/run/1051/auxroot/include -I/root/.xbuilder/run/1051/auxroot/include/tirpc -DPy_BUILD_CORE_BUILTIN -c ./Modules/timemodule.c -o Modules/timemodule.o 2025-02-27T04:16:41.0793065Z In file included from ./Include/Python.h:64, 2025-02-27T04:16:41.0798014Z from ./Modules/timemodule.c:3: 2025-02-27T04:16:41.0798662Z ./Modules/timemodule.c: In function 'time_clockid_converter': 2025-02-27T04:16:41.0799495Z ./Include/pymacro.h:23:25: error: static assertion failed: "sizeof(clk_id) == sizeof(*p)" 2025-02-27T04:16:41.0800210Z # define static_assert _Static_assert 2025-02-27T04:16:41.0800628Z ^~~~~~~~~~~~~~ 2025-02-27T04:16:41.0801204Z ./Include/pymacro.h:77:13: note: in expansion of macro 'static_assert' 2025-02-27T04:16:41.0801791Z static_assert((cond), #cond); \ 2025-02-27T04:16:41.0802179Z ^~~~~~~~~~~~~ 2025-02-27T04:16:41.0802658Z ./Modules/timemodule.c:201:5: note: in expansion of macro 'Py_BUILD_ASSERT' 2025-02-27T04:16:41.0803366Z Py_BUILD_ASSERT(sizeof(clk_id) == sizeof(*p)); 2025-02-27T04:16:41.0803764Z ^~~~~~~~~~~~~~~ 2025-02-27T04:16:41.1033318Z gmake: *** [Makefile:3534: Modules/timemodule.o] Error 1 2025-02-27T04:16:41.1037795Z gmake: *** Waiting for unfinished jobs.... ``` fulllogs: https://github.com/leleliu008/python-distribution/actions/runs/13558699714/job/37897846484 ### CPython versions tested on: 3.13 https://www.python.org/ftp/python/3.13.2/Python-3.13.2.tgz ### Operating systems tested on: DragonFlyBSD-6.4 <!-- gh-linked-prs --> ### Linked PRs * gh-130634 * gh-130666 <!-- /gh-linked-prs -->
e41981704f0a6adb58c3e258b4226619521ce03c
9211b3dabeacb92713ac3f5f0fa43bc7cf69afd8
python/cpython
python__cpython-130610
# Remove `dirs_exist_ok` argument from `pathlib.Path.copy()` (Background: [`pathlib.Path.copy()`](https://docs.python.org/3.14/library/pathlib.html#pathlib.Path.copy) is new in Python 3.14, so it hasn't been released yet.) I don't think there's a compelling case to support a *dirs_exist_ok* argument in the initial version of `Path.copy()`. Most Python users don't need "copy and merge directory" functionality. Particularly unlucky users might use the wrong source or target path, and perform a large directory tree merge that is difficult to unpick. We could add this back in later, in response to user demand. <!-- gh-linked-prs --> ### Linked PRs * gh-130610 <!-- /gh-linked-prs -->
b5454509612870dd0e09aaba4b79865a5faad284
fdcbc29f26448f47201ec40fcf3b6405631c85d3
python/cpython
python__cpython-121518
# Missing IPv6 testcase for for IPv6 with part of IPv4 # Feature or enhancement ### Proposal: The same IPv6 address can be writed different ways, one of which is extended IPv4 form, like '::1.2.3.4', which may be detect as IPv4 by mistake. Thats why we must be sure, that ipaddress correctly detect this IPv6 address as IPv6, and compare with another forms of this address. Something like that is needed @```python assert ipaddress.IPv6Interface('::1.2.3.4') == ipaddress.IPv6Interface('0000:0000:0000:0000:0000:0000:0102:0304') assert ipaddress.IPv6Interface('::1.2.3.4').version == 6 ``` ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: https://github.com/python/cpython/pull/121518 <!-- gh-linked-prs --> ### Linked PRs * gh-121518 * gh-130678 * gh-130679 <!-- /gh-linked-prs -->
9f0879baf15fdcf89f1b85cc244d596d4d0f4e47
830f04b5056db92ba96387db0a778dcd19a39522
python/cpython
python__cpython-130606
# `test_concurrent_futures` TSAN failures # Bug report I enabled `test_concurrent_futures` in the thread sanitizer job yesterday in: * https://github.com/python/cpython/pull/129826 Unfortunately, this is causing fairly frequent failures in the TSAN job, especially for the default (GIL-enabled) build, which I hadn't tested sufficiently with TSAN. I'll temporarily remove `test_concurrent_futures` while I work on fixing the races. ## Races ### `take_gil` and `_PyEval_SetSwitchInterval` ``` WARNING: ThreadSanitizer: data race (pid=9777) Read of size 8 at 0x55e09fe6ae08 by thread T24 (mutexes: write M0): #0 take_gil /home/runner/work/cpython/cpython/Python/ceval_gil.c:328:40 (python+0x4fef47) (BuildId: bc0ef96fe091f729b109ca39e0975c49764059f7) #1 _PyEval_AcquireLock /home/runner/work/cpython/cpython/Python/ceval_gil.c:586:5 (python+0x4ff62e) (BuildId: bc0ef96fe091f729b109ca39e0975c49764059f7) #2 _PyThreadState_Attach /home/runner/work/cpython/cpython/Python/pystate.c:2092:9 (python+0x571225) (BuildId: bc0ef96fe091f729b109ca39e0975c49764059f7) #3 PyEval_AcquireThread /home/runner/work/cpython/cpython/Python/ceval_gil.c:603:5 (python+0x4ff6fe) (BuildId: bc0ef96fe091f729b109ca39e0975c49764059f7) ... Previous write of size 8 at 0x55e09fe6ae08 by main thread: #0 _PyEval_SetSwitchInterval /home/runner/work/cpython/cpython/Python/ceval_gil.c:423:19 (python+0x4fe71a) (BuildId: bc0ef96fe091f729b109ca39e0975c49764059f7) #1 sys_setswitchinterval_impl /home/runner/work/cpython/cpython/./Python/sysmodule.c:1313:5 (python+0x598ae8) (BuildId: bc0ef96fe091f729b109ca[39](https://github.com/python/cpython/actions/runs/13552992546/job/37880869299?pr=130602#step:14:40)e0975c49764059f7) #2 sys_setswitchinterval /home/runner/work/cpython/cpython/./Python/clinic/sysmodule.c.h:529:20 (python+0x598ae8) #3 cfunction_vectorcall_O /home/runner/work/cpython/cpython/Objects/methodobject.c:523:24 (python+0x2eb8bd) (BuildId: bc0ef96fe091f729b109ca39e0975c4976[40](https://github.com/python/cpython/actions/runs/13552992546/job/37880869299?pr=130602#step:14:41)59f7) ... SUMMARY: ThreadSanitizer: data race /home/runner/work/cpython/cpython/Python/ceval_gil.c:328:40 in take_gil ``` <!-- gh-linked-prs --> ### Linked PRs * gh-130606 * gh-130654 * gh-135790 <!-- /gh-linked-prs -->
959f43315e165a868888808d30025785d4ae3e7c
b251d409f9cf6a84e6d7a78d284467f57c97a63a
python/cpython
python__cpython-130603
# Use `fail-fast: false` for thread sanitizer CI The thread sanitizer CI fails often enough that I think we want to use `fail-fast: false` so that a thread sanitizer failure doesn't cancel other running CI jobs that are part of the same workflow. Suggested by @AA-Turner. <!-- gh-linked-prs --> ### Linked PRs * gh-130603 * gh-130612 * gh-130613 <!-- /gh-linked-prs -->
fda056e64bdfcac3dd3d13eebda0a24994d83cb8
959f43315e165a868888808d30025785d4ae3e7c
python/cpython
python__cpython-130588
# token module documentation is incomplete # Documentation The [`token` docs](https://docs.python.org/3/library/token.html) use a generated list of tokens, with short blurbs for the OP tokens but nothing for the other (more interesting) ones. Some tokens (`COMMENT`, `NL`, etc.) have secondary, hand-written definitions. However, these are excluded from the index; [links](https://docs.python.org/3/library/token.html#token.COMMENT) go to the empty entries. I propose adding hand-written prose for the non-OP tokens, and changing the automation to *check* the entries rather than generate them. For the OP tokens, generating the docs is the correct thing to do, but the list can be more compact since they're all the same. <!-- gh-linked-prs --> ### Linked PRs * gh-130588 * gh-131465 * gh-132304 * gh-132327 <!-- /gh-linked-prs -->
4bced29a74c4dbcf310a47e8202292aaa39b617b
b8367e7cf3d740fdc401902b502c0ef2ccc6197c
python/cpython
python__cpython-130685
# We are running out of space for specialized opcodes The opcode space is laid out as follows: * Normal instructions * Gap (>30 instructions) * RESUME (opcode 149) * Specialized instructions * Gap (3 instructions) * Instrumented instruments If we need to add four more specializations and/or instrumented instructions we will run out of space. The fix is obvious: Renumber RESUME to something like 128. <!-- gh-linked-prs --> ### Linked PRs * gh-130685 <!-- /gh-linked-prs -->
aeb23273867b27818a3dabd5fca086a1a2e8d229
e4a60248b031d9e327443f1f2627e66865f8a9c9
python/cpython
python__cpython-130778
# Race between `dict_dealloc` and `split_keys_entry_added` under free threading # Bug report ### Bug description: In the following code it appears we race on the `dk_nentries` of a split keys dict. ```python import concurrent.futures import functools import threading import _testcapi num_threads = 32 def closure(b, i): b.wait() h = _testcapi.HeapCTypeWithManagedDict() h.__dict__[f"asdf{i}"] = "bar" with concurrent.futures.ThreadPoolExecutor(max_workers=num_threads) as executor: for i in range(1000): b = threading.Barrier(num_threads) for i in range(num_threads): executor.submit(functools.partial(closure, b, i)) ``` TSAN report: ``` WARNING: ThreadSanitizer: data race (pid=3466735) Read of size 8 at 0x7ffa06cba218 by thread T32: #0 dict_dealloc /usr/local/google/home/phawkins/p/cpython/Objects/dictobject.c:3170:42 (python3.13+0x26b02f) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #1 _Py_Dealloc /usr/local/google/home/phawkins/p/cpython/Objects/object.c:2935:5 (python3.13+0x2906a2) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #2 _Py_MergeZeroLocalRefcount /usr/local/google/home/phawkins/p/cpython/Objects/object.c (python3.13+0x2906a2) #3 Py_DECREF /usr/local/google/home/phawkins/p/cpython/./Include/object.h:913:13 (python3.13+0x271cf7) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #4 Py_XDECREF /usr/local/google/home/phawkins/p/cpython/./Include/object.h:1042:9 (python3.13+0x271cf7) #5 _PyObject_SetManagedDict /usr/local/google/home/phawkins/p/cpython/Objects/dictobject.c:7151:13 (python3.13+0x271cf7) #6 PyObject_ClearManagedDict /usr/local/google/home/phawkins/p/cpython/Objects/dictobject.c:7175:9 (python3.13+0x272317) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #7 heapmanaged_dealloc /usr/local/google/home/phawkins/p/cpython/./Modules/_testcapi/heaptype.c:822:5 (_testcapi.cpython-313t-x86_64-linux-gnu.so+0x21566) (BuildId: bcb92e2e6763ccff2c40c066ebaf418e7c3dee07) #8 _Py_Dealloc /usr/local/google/home/phawkins/p/cpython/Objects/object.c:2935:5 (python3.13+0x2906a2) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #9 _Py_MergeZeroLocalRefcount /usr/local/google/home/phawkins/p/cpython/Objects/object.c (python3.13+0x2906a2) #10 Py_DECREF /usr/local/google/home/phawkins/p/cpython/./Include/object.h:913:13 (python3.13+0x227b98) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #11 frame_dealloc /usr/local/google/home/phawkins/p/cpython/Objects/frameobject.c:1728:13 (python3.13+0x227b98) #12 _Py_Dealloc /usr/local/google/home/phawkins/p/cpython/Objects/object.c:2935:5 (python3.13+0x2906a2) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #13 _Py_MergeZeroLocalRefcount /usr/local/google/home/phawkins/p/cpython/Objects/object.c (python3.13+0x2906a2) #14 Py_DECREF /usr/local/google/home/phawkins/p/cpython/./Include/object.h:913:13 (python3.13+0x4bde23) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #15 Py_XDECREF /usr/local/google/home/phawkins/p/cpython/./Include/object.h:1042:9 (python3.13+0x4bde23) #16 tb_dealloc /usr/local/google/home/phawkins/p/cpython/Python/traceback.c:188:5 (python3.13+0x4bde23) #17 _Py_Dealloc /usr/local/google/home/phawkins/p/cpython/Objects/object.c:2935:5 (python3.13+0x2906a2) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #18 _Py_MergeZeroLocalRefcount /usr/local/google/home/phawkins/p/cpython/Objects/object.c (python3.13+0x2906a2) #19 Py_DECREF /usr/local/google/home/phawkins/p/cpython/./Include/object.h:913:13 (python3.13+0x4bdda3) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #20 Py_XDECREF /usr/local/google/home/phawkins/p/cpython/./Include/object.h:1042:9 (python3.13+0x4bdda3) #21 tb_dealloc /usr/local/google/home/phawkins/p/cpython/Python/traceback.c:187:5 (python3.13+0x4bdda3) #22 _Py_Dealloc /usr/local/google/home/phawkins/p/cpython/Objects/object.c:2935:5 (python3.13+0x2906a2) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #23 _Py_MergeZeroLocalRefcount /usr/local/google/home/phawkins/p/cpython/Objects/object.c (python3.13+0x2906a2) #24 Py_DECREF /usr/local/google/home/phawkins/p/cpython/./Include/object.h:913:13 (python3.13+0x209a86) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #25 BaseException_clear /usr/local/google/home/phawkins/p/cpython/Objects/exceptions.c:87:5 (python3.13+0x209a86) #26 NameError_clear /usr/local/google/home/phawkins/p/cpython/Objects/exceptions.c:2228:12 (python3.13+0x210fac) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #27 NameError_dealloc /usr/local/google/home/phawkins/p/cpython/Objects/exceptions.c:2235:5 (python3.13+0x210fac) #28 _Py_Dealloc /usr/local/google/home/phawkins/p/cpython/Objects/object.c:2935:5 (python3.13+0x2904a5) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #29 merge_queued_objects /usr/local/google/home/phawkins/p/cpython/Python/brc.c:110:13 (python3.13+0x3dca2a) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #30 _Py_brc_merge_refcounts /usr/local/google/home/phawkins/p/cpython/Python/brc.c:131:5 (python3.13+0x3dca2a) #31 _Py_HandlePending /usr/local/google/home/phawkins/p/cpython/Python/ceval_gil.c:1289:9 (python3.13+0x45358e) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #32 _PyEval_EvalFrameDefault /usr/local/google/home/phawkins/p/cpython/Python/generated_cases.c.h:5160:17 (python3.13+0x3f2f00) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #33 _PyEval_EvalFrame /usr/local/google/home/phawkins/p/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3de77a) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #34 _PyEval_Vector /usr/local/google/home/phawkins/p/cpython/Python/ceval.c:1812:12 (python3.13+0x3de77a) #35 _PyFunction_Vectorcall /usr/local/google/home/phawkins/p/cpython/Objects/call.c (python3.13+0x1eb3bf) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #36 _PyObject_VectorcallTstate /usr/local/google/home/phawkins/p/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x1ef2d5) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #37 method_vectorcall /usr/local/google/home/phawkins/p/cpython/Objects/classobject.c:62:18 (python3.13+0x1ef2d5) #38 _PyObject_VectorcallTstate /usr/local/google/home/phawkins/p/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x1ead4a) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #39 PyObject_Vectorcall /usr/local/google/home/phawkins/p/cpython/Objects/call.c:327:12 (python3.13+0x1ead4a) #40 _PyEval_EvalFrameDefault /usr/local/google/home/phawkins/p/cpython/Python/generated_cases.c.h:813:23 (python3.13+0x3e264b) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #41 _PyEval_EvalFrame /usr/local/google/home/phawkins/p/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3de77a) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #42 _PyEval_Vector /usr/local/google/home/phawkins/p/cpython/Python/ceval.c:1812:12 (python3.13+0x3de77a) #43 _PyFunction_Vectorcall /usr/local/google/home/phawkins/p/cpython/Objects/call.c (python3.13+0x1eb3bf) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #44 _PyObject_VectorcallTstate /usr/local/google/home/phawkins/p/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x1ef38f) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #45 method_vectorcall /usr/local/google/home/phawkins/p/cpython/Objects/classobject.c:70:20 (python3.13+0x1ef38f) #46 _PyVectorcall_Call /usr/local/google/home/phawkins/p/cpython/Objects/call.c:273:16 (python3.13+0x1eb033) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #47 _PyObject_Call /usr/local/google/home/phawkins/p/cpython/Objects/call.c:348:16 (python3.13+0x1eb033) #48 PyObject_Call /usr/local/google/home/phawkins/p/cpython/Objects/call.c:373:12 (python3.13+0x1eb0b5) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #49 thread_run /usr/local/google/home/phawkins/p/cpython/./Modules/_threadmodule.c:337:21 (python3.13+0x5649a2) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #50 pythread_wrapper /usr/local/google/home/phawkins/p/cpython/Python/thread_pthread.h:243:5 (python3.13+0x4bdca7) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) Previous atomic write of size 8 at 0x7ffa06cba218 by thread T2: #0 _Py_atomic_store_ssize_relaxed /usr/local/google/home/phawkins/p/cpython/./Include/cpython/pyatomic_gcc.h:481:3 (python3.13+0x273284) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #1 split_keys_entry_added /usr/local/google/home/phawkins/p/cpython/Objects/dictobject.c:225:5 (python3.13+0x273284) #2 insert_split_key /usr/local/google/home/phawkins/p/cpython/Objects/dictobject.c:1743:9 (python3.13+0x273284) #3 insertdict /usr/local/google/home/phawkins/p/cpython/Objects/dictobject.c:1796:25 (python3.13+0x263496) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #4 setitem_take2_lock_held /usr/local/google/home/phawkins/p/cpython/Objects/dictobject.c:2507:12 (python3.13+0x262996) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #5 _PyDict_SetItem_Take2 /usr/local/google/home/phawkins/p/cpython/Objects/dictobject.c:2515:11 (python3.13+0x262bcf) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #6 PyDict_SetItem /usr/local/google/home/phawkins/p/cpython/Objects/dictobject.c:2535:12 (python3.13+0x262bcf) #7 dict_ass_sub /usr/local/google/home/phawkins/p/cpython/Objects/dictobject.c:3340:16 (python3.13+0x27557a) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #8 PyObject_SetItem /usr/local/google/home/phawkins/p/cpython/Objects/abstract.c:232:19 (python3.13+0x1b9488) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #9 _PyEval_EvalFrameDefault /usr/local/google/home/phawkins/p/cpython/Python/generated_cases.c.h:5777:27 (python3.13+0x3f5d0b) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #10 _PyEval_EvalFrame /usr/local/google/home/phawkins/p/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3de77a) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #11 _PyEval_Vector /usr/local/google/home/phawkins/p/cpython/Python/ceval.c:1812:12 (python3.13+0x3de77a) #12 _PyFunction_Vectorcall /usr/local/google/home/phawkins/p/cpython/Objects/call.c (python3.13+0x1eb3bf) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #13 _PyObject_VectorcallTstate /usr/local/google/home/phawkins/p/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x5722c2) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #14 partial_vectorcall /usr/local/google/home/phawkins/p/cpython/./Modules/_functoolsmodule.c:252:16 (python3.13+0x5722c2) #15 _PyVectorcall_Call /usr/local/google/home/phawkins/p/cpython/Objects/call.c:273:16 (python3.13+0x1eb033) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #16 _PyObject_Call /usr/local/google/home/phawkins/p/cpython/Objects/call.c:348:16 (python3.13+0x1eb033) #17 PyObject_Call /usr/local/google/home/phawkins/p/cpython/Objects/call.c:373:12 (python3.13+0x1eb0b5) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #18 _PyEval_EvalFrameDefault /usr/local/google/home/phawkins/p/cpython/Python/generated_cases.c.h:1355:26 (python3.13+0x3e4832) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #19 _PyEval_EvalFrame /usr/local/google/home/phawkins/p/cpython/./Include/internal/pycore_ceval.h:119:16 (python3.13+0x3de77a) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #20 _PyEval_Vector /usr/local/google/home/phawkins/p/cpython/Python/ceval.c:1812:12 (python3.13+0x3de77a) #21 _PyFunction_Vectorcall /usr/local/google/home/phawkins/p/cpython/Objects/call.c (python3.13+0x1eb3bf) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #22 _PyObject_VectorcallTstate /usr/local/google/home/phawkins/p/cpython/./Include/internal/pycore_call.h:168:11 (python3.13+0x1ef38f) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #23 method_vectorcall /usr/local/google/home/phawkins/p/cpython/Objects/classobject.c:70:20 (python3.13+0x1ef38f) #24 _PyVectorcall_Call /usr/local/google/home/phawkins/p/cpython/Objects/call.c:273:16 (python3.13+0x1eb033) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #25 _PyObject_Call /usr/local/google/home/phawkins/p/cpython/Objects/call.c:348:16 (python3.13+0x1eb033) #26 PyObject_Call /usr/local/google/home/phawkins/p/cpython/Objects/call.c:373:12 (python3.13+0x1eb0b5) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #27 thread_run /usr/local/google/home/phawkins/p/cpython/./Modules/_threadmodule.c:337:21 (python3.13+0x5649a2) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) #28 pythread_wrapper /usr/local/google/home/phawkins/p/cpython/Python/thread_pthread.h:243:5 (python3.13+0x4bdca7) (BuildId: eba64ecb5d6238e288495b7377dad10e1b152da3) ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130778 * gh-130833 <!-- /gh-linked-prs -->
80e6d3ec4972220587c8b883161311a49ea8d0ff
d91cc9db155024b0a221cf32f4f49617544618bf
python/cpython
python__cpython-131537
# threading: Exception at shutdown on musllinux_1_2_i686 # Bug report ### Bug description: When `cibuildwheel` runs the `musllinux_1_2_i686` configuration, I often see exceptions logged when the end-of-process GC runs: ``` Exception ignored in: <function _DeleteDummyThreadOnDel.__del__ at 0xf2be5578> Traceback (most recent call last): File "/opt/_internal/cpython-3.13.0/lib/python3.13/threading.py", line 1383, in __del__ TypeError: 'NoneType' object does not support the context manager protocol .Traceback (most recent call last): File "<string>", line 1, in <module> from tornado.ioloop import IOLoop; classname = lambda x: x.__class__.__name__; from tornado.platform.asyncio import AsyncIOMainLoop; AsyncIOMainLoop().install(); print(classname(IOLoop.current())) ``` It looks like something about musl libc is causing `_active_limbo_lock` to get GC'd before `_thread_local_info._track_dummy_thread_ref`. This happens on musllinux (1.2) on i686 builds. 64-bit builds (of x86 and arm) and manylinux builds are not affected. Older versions of python are not affected; I have not tested with 3.14 alphas but I think they are likely affected since the relevant code doesn't appear to have changed. A complete log with this failure can be found at https://github.com/bdarnell/tornado/actions/runs/13459578244/job/37733273132 This issue is not a priority for me. I'm just going to skip this configuration in my CI and I'm filing an issue so I have something to point to. ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-131537 * gh-137105 * gh-137106 <!-- /gh-linked-prs -->
cb93b6fc5ea525f8075cb53ec373356fec63903a
7ce2f101c4b1c123860c90bf67ccc20a7805ea48
python/cpython
python__cpython-130523
# Add meta tags for template pages https://github.com/python/docs-community/issues/65 added generation for most pages excluding the template pages leaving us with no meta tags for the most important pages! <!-- gh-linked-prs --> ### Linked PRs * gh-130523 * gh-132238 * gh-132239 <!-- /gh-linked-prs -->
f5639d87f59043d3075dbd3d9075f30e872dd91a
c0de6500249469e6fc5b458d6afb6bad1b6755cd
python/cpython
python__cpython-130553
# `test_free_threading.test_dict` on TSAN/free-threading is flaky # Bug report ### Bug description: We have: ``` 0:04:15 load avg: 7.63 [20/23/2] test_free_threading worker non-zero exit code (Exit code -6 (SIGABRT)) -- running (2): test_socket (1 min 38 sec), test_threading (38.8 sec) python: Objects/obmalloc.c:1219: void process_queue(struct llist_node *, struct _qsbr_thread_state *, _Bool, delayed_dealloc_cb, void *): Assertion `buf->rd_idx == buf->wr_idx' failed. Fatal Python error: Aborted <Cannot show all threads while the GIL is disabled> Stack (most recent call first): File "/home/runner/work/cpython/cpython/Lib/test/test_free_threading/test_dict.py", line 184 in writer_func File "/home/runner/work/cpython/cpython/Lib/threading.py", line 996 in run File "/home/runner/work/cpython/cpython/Lib/threading.py", line 1054 in _bootstrap_inner File "/home/runner/work/cpython/cpython/Lib/threading.py", line 1016 in _bootstrap Extension modules: _testinternalcapi, _testcapi (total: 2) ``` I'm not sure if it's a real bug or not. Victor suggested me to open an issue for this one. Maybe there's already one that exists though. See https://github.com/python/cpython/actions/runs/13225352402/job/36915529351?pr=129175#step:12:44 for the log (hopefully it will stay). ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130553 <!-- /gh-linked-prs -->
45bc120d4504bff215938bca3f1d08cee2ed7a91
5c8e8704c39110da15956b0678303aff7dffb3be
python/cpython
python__cpython-130487
# test_venv fails from within venv # Bug report ### Bug description: The test_venv tests were too strict about executable names, causing failures when running the test suite from within a virtual environment created from the built Python. Rather than enforcing specific executable names, it makes more sense to make the tests more flexible to support testing in both contexts - directly from build and from within a venv. What do you think about it? ```bash # build ./configure && make -j # create venv ./python.exe -m venv .venv source .venv/bin/activate # this will fail python -m test test_venv ``` Also reproduced on Windows ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-130487 <!-- /gh-linked-prs -->
d780f0af2bd7b9ef8cf46d28c5d495d1c980b1f0
813bc5694bd8aa43165468c5ea1dc27af973611d
python/cpython
python__cpython-130502
# add ability to specify name for `tk.OptionMenu` and `ttk.OptionMenu` # Feature or enhancement ### Proposal: In current implementation of `tk.OptionMenu` and `ttk.OptionMenu`, we can not specify name to them since adding additional `kwargs` raises `unknown option` error Since after initialization of widget `name` cannot be changed, hence we cannot specify custom name such as `games_option_menu` etc to the `OptionMenu`. Ability to specify name to a widget is very handy, since it helps programmer to easily gain access to widget between diffrent scopes and this ability is lacking in `OptionMenu` widget. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130502 <!-- /gh-linked-prs -->
e490c00dac16d458bb66ad157fda2edd0a2d0a14
1e9cc3d502773d2dd3b420ecf5b949d902e010c3
python/cpython
python__cpython-130481
# Move duplicate `LOAD_SMALL_INT` optimization from codegen to CFG # Feature or enhancement ### Proposal: Addressing https://github.com/python/cpython/pull/129568#discussion_r1938588949 Currently both codegen & peepholer optimize `LOAD_CONST` for small integers to `LOAD_SMALL_INT`. CFG can do it alone, so we don't have this logic in 2 places. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130481 <!-- /gh-linked-prs -->
55815a6474c59001f0230e44560341b643268e87
26511993e63265ea5928aabe6af96d89e20f0553
python/cpython
python__cpython-134177
# Compilation of HACL fails under macOS Silicon for version 3.14 # Bug report ### Bug description: Related issues: #123748, #130366, #129043 Problem: In Python 3.14.0a5, when compiling on macOS Silicon without specifying the `--enable-universalsdk` parameter (as there is no need to compile a universal version for x86_64 & arm64), an error "unknown type name 'Lib_IntVector_Intrinsics_vec256'" occurs. Compilation parameters: ```bash ./configure --prefix=/Applications/ServBay/package/python/3.14/3.14.0a5 --enable-ipv6 --enable-loadable-sqlite-extensions --with-openssl=/Applications/ServBay/package/common/openssl/3.2 --enable-optimizations --with-system-expat --with-system-libmpdec --with-readline=editline --with-lto --enable-framework=/Applications/ServBay/package/python/3.14/3.14.0a5 ``` Problem analysis: The Python team previously released a patch for this issue, but in the `configure` and `configure.ac` scripts, the patch uses the `$UNIVERSAL_ARCHS` parameter for condition checks. This fix does not completely resolve the issue because `$UNIVERSAL_ARCHS` depends on the `--enable-universalsdk` parameter being passed. Without this parameter, the initial value of `$UNIVERSAL_ARCHS` is `UNIVERSAL_ARCHS="32-bit"`, leading to the condition `if test "$UNIVERSAL_ARCHS" != "universal2"; then` not being effective. Partial configure log: ```bash Python 3.9+ detected checking build system type... aarch64-apple-darwin23.5.0 checking host system type... aarch64-apple-darwin23.5.0 checking for Python interpreter freezing... ./_bootstrap_python checking for python3.14... no checking for python3.13... no checking for python3.12... python3.12 checking Python for regen version... Python 3.12.5 checking pkg-config is at least version 0.9.0... yes checking MACHDEP... "darwin" checking for --enable-universalsdk... no checking for --with-universal-archs... no checking for --with-app-store-compliance... not patching for app store compliance checking for xcrun... yes checking macOS SDKROOT... /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether the compiler supports GNU C... yes checking whether gcc accepts -g... yes checking for gcc option to enable C11 features... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for a sed that does not truncate output... /usr/bin/sed checking for egrep... /usr/bin/grep -E checking for CC compiler name... clang // blablabla ``` Repair solution: In the `configure` and `configure.ac` scripts, it is necessary to use other conditions for checks instead of relying on `$UNIVERSAL_ARCHS`. Attached is a quick fix patch based on `build_cpu` and `build_vendor`. However, this is not the most appropriate solution. https://github.com/user-attachments/files/18921691/fixed-hacl-arm64.patch ### CPython versions tested on: 3.14 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-134177 * gh-134188 * gh-135009 <!-- /gh-linked-prs -->
5130a4d5d74b19d704099cb40758527c1894185a
4672060d86722e7daf946220812613938c54a5eb
python/cpython
python__cpython-130436
# The documentation for `MultipartConversionError` is outdated # Documentation [The document](https://docs.python.org/ja/3.14/library/email.errors.html#email.errors.MultipartConversionError) mentions the `add_payload` method, but `add_payload` no longer exists and has been replaced by `attach`. This exception seems to only be raised by `attach`. <!-- gh-linked-prs --> ### Linked PRs * gh-130436 * gh-130565 * gh-130566 <!-- /gh-linked-prs -->
b536e371044f9e9b1b34cc8276a01e67550b5428
baae9cb159e240ee9474ce7c02f88c233390777a
python/cpython
python__cpython-130420
# Do not build the freeze module twice in case of Windows PGO builds # Feature or enhancement ### Proposal: From https://github.com/python/cpython/pull/129907#issuecomment-2648775431 > Avoiding the rebuild of `_freeze_module` and the refreezing would be nice, but it's not a huge deal (a few seconds in a ~hour long release process). Don't mix it in with this PR. This is another low hanging fruit to make the Windows PGO build slightly faster (like https://github.com/python/cpython/issues/90281 did) by not building the _freeze_module again in the PGUpdate phase. This will decrease both the MSVC and the clang-cl PGO build time (https://github.com/python/cpython/issues/130090). In case of clang-cl, this saves me up to 40 seconds on my machine. Please see https://github.com/python/cpython/pull/131005 `Details pgupdate build times` for more numbers ### 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-130420 <!-- /gh-linked-prs -->
3a555f09f387a0212e5961535ae4e31178b26c11
78e09a488d41066dea5f8dcf22405a0d5dd8be23
python/cpython
python__cpython-130385
# `test_sys.SysModuleTest.get_allocated_blocks` test precondition intermittently fails on iOS # Bug report ### Bug description: #130007 introduced a change to the handling of C stack limits. This change intermittently causes the `test_sys.SysModuleTest.get_allocated_blocks()` test to fail: ``` ====================================================================== FAIL: test_getallocatedblocks (test.test_sys.SysModuleTest.test_getallocatedblocks) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/buildbot/Library/Developer/XCTestDevices/AFB8404B-0B3C-4CD4-862A-BBCE48F86959/data/Containers/Bundle/Application/91D9D3A2-F680-47B8-AC8F-A68603BDDACC/iOSTestbed.app/python/lib/python3.14/test/test_sys.py", line 1104, in test_getallocatedblocks self.assertLess(a, sys.gettotalrefcount()) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: 548518 not less than 476363 ---------------------------------------------------------------------- ``` The exact values vary, but they're usually within ~500 or so. On the test re-run, the values are different: ``` AssertionError: 592958 not less than 518066 ``` (again, varying between test runs by ~500 or so). @markshannon commented on the original PR: > `sys.gettotalrefcount()` is the total refcount per interpreter, but `sys.getallocatedblocks()` seems to be the total number of allocated blocks per process. If multiple interpreters were involved, I could see this test failing. Otherwise, it is puzzling. > > This PR does no refcounting, allocation or deallocation. My guess is that this PR is exposing an already existing miscounting of references when a recursion error occurs. Just a guess though. The problem doesn't appear to be an issue with running the test suite as a single process - Android isn't affected in CI, I can't reproduce the issue on my own macOS machine running a single-process run locally. However, I also can't reliably reproduce the problem locally on iOS. Running the fully test suite locally, this test passes reliably. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-130385 <!-- /gh-linked-prs -->
8a76eb846926384a48bb1997bbf5c162fe29fc5d
7ed3dc6392613832f66c63507385b1da109cbf21
python/cpython
python__cpython-130689
# Py_DECREF() in interpreter doesn't call `_PyReftracerTrack(op, PyRefTracer_DESTROY)` # Bug report https://github.com/python/cpython/blob/6c450f44c283c61d0e1ada05ead9524a1fe97962/Python/ceval.c#L72-L85 Tracemalloc only handles `PyRefTracer_CREATE` events and we don't have any tests for `PyRefTracer_DESTROY` events. **EDIT:** `_testcapimodule.c` tests `PyRefTracer_DESTROY` events, but only through the C API and not the Python interpreter. <!-- gh-linked-prs --> ### Linked PRs * gh-130689 * gh-130700 * gh-131195 <!-- /gh-linked-prs -->
c5abded09995f208b21ebaf012185ca5acb0180b
3a91ee97245639c7c4f8852418157d3fc0ec1a82
python/cpython
python__cpython-130509
# Zipapp archives are always empty # Bug report ### Bug description: Good evening, I have recently installed Python 3.13 (Windows x64) over 3.12. Now `zipapp.create_archive(..)` is creating just empty archives. After some fiddling around I found there might be an issue in these lines: (from zipapp.py, lines 113 ff) ``` with _maybe_open(target, 'wb') as fd: _write_file_prefix(fd, interpreter) compression = (zipfile.ZIP_DEFLATED if compressed else zipfile.ZIP_STORED) with zipfile.ZipFile(fd, 'w', compression=compression) as z: for child in sorted(source.rglob('*')): arcname = child.relative_to(source) if filter is None or filter(arcname) and child.resolve() != arcname.resolve(): # ██ LOOK HERE ! ██ z.write(child, arcname.as_posix()) if main_py: z.writestr('__main__.py', main_py.encode('utf-8')) ``` This change was introduced in Python 3.13 (have verified against 3.12 sources) and seemingly causes the trouble. My guess is, as `child` is pointing to the same file as `arcname`, and naturally, they both resolve to the same file, no file gets added due to the `!=` check, ever, to the archive-to-be-created. Maybe it was intended to check against `target`, not `arcname`? Once I monkeypatched the `and child.resolve() != arcname.resolve()` part away, the archive got written again. Or am I just not doing it right? Any help much appreciated! Sebastian. ### CPython versions tested on: 3.13 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-130509 * gh-130791 <!-- /gh-linked-prs -->
64ccbbbf367c7510090a6f5faf826a21102a8bc6
f976892b7db011f3f039be615f4a759b8c487db3
python/cpython
python__cpython-130372
# _LOAD_ATTR_WITH_HINT should be able to work lock-free in the free-threaded builds # Feature or enhancement ### Proposal: This is just doing a dictionary lookup, which we can do lock-free. We should do the same thing we do for lock free dict lookups using the hinted location. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130372 <!-- /gh-linked-prs -->
2984ff9e5196aa575c7322c2040d55dd4d4eaa02
00f0771e4dbd8c8b66b302ebc16bb21f5d46b304
python/cpython
python__cpython-132349
# asyncio: Re-reverse deprecation of set_event_loop? # Feature or enhancement ### Proposal: The asyncio policy system is deprecated in python 3.14 (#127949). As implemented, this includes the `asyncio.set_event_loop()` function. However, in 2022, [it was decided](https://github.com/python/cpython/pull/98440#issuecomment-1334030286) that `set_event_loop` and `get_event_loop` (just the thread-local storage, not the broader policy system) were serving a useful and separate purpose and should be kept around. I [relied on this decision](https://github.com/tornadoweb/tornado/issues/3216) in Tornado to adapt to various changes while staying on interfaces that I thought would be safe from deprecation. I would like to briefly bring this up for reconsideration since this is a reversal of a decision from just a few years ago and it appears to have been lumped in with the rest of the policy system without consideration on its own. If the decision to deprecate this function stands, I'll be able to adapt in Tornado, but it will be inconvenient: I think I'll have to use asyncio.Runner which was introduced in 3.11, while I'm still supporting 3.9 and 3.10 for another couple of years. ## Background Here's the history as I remember it. In Python 3.10, the policy system was deprecated and slated for removal in 3.12. When the 3.12 alphas were released with the policy methods removed, we found that there were code paths that relied on the deprecated methods without emitting suitable warnings, leading to surprise breakages. This caused everything to be reset (in 3.10.9 and 3.11.1, which is why those specific versions are [cited in the docs](https://docs.python.org/3.10/library/asyncio-policy.html)). Deprecation notices were removed, but the understanding at the time was that this was just resetting the clock and policies would still be going away, just a few years later. Separately, there was a debate about the set_event_loop function, although I can't find the right thread now. (https://github.com/python/cpython/issues/83710#issuecomment-1093855418 and https://github.com/python/cpython/pull/98440#issuecomment-1334030286 are related, but I can't find where the actual conclusion was reached). I think Jupyter was another project where `set_event_loop` turned out to be important? ### 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-132349 <!-- /gh-linked-prs -->
05d27a84f4a85d777239e95e6d9b6dae8b32c538
e6ef47ac229b5c4a62b9c907e4232e350db77ce3
python/cpython
python__cpython-130321
# gettext: Missing tests for fallback translations For `NullTranslations` and `GNUTranslations` instances, it is possible to add a fallback that is invoked when a translation is not found via `t.add_fallback(fallback)`. However, this is currently not tested, neither for `NullTranslations`, nor for `GNUTranslations`. We should test this behaviour. <!-- gh-linked-prs --> ### Linked PRs * gh-130321 * gh-132359 <!-- /gh-linked-prs -->
4d58c8cb247b585051bfbacd79f77aafd18986b7
4a88bbacb38934a7f6c6ba7a7976cbf877dbae21
python/cpython
python__cpython-130452
# struct (un)packing of half-precision `nan` floats is non-invertible # Bug report ### Bug description: I noticed that chaining `struct.unpack()` and `struct.pack()` for IEEE 754 Half Precision floats (`e`) is non-invertible for `nan`. E.g.: ```python import struct original_bytes = b'\xff\xff' unpacked_float = struct.unpack('e', original_bytes)[0] # nan repacked_bytes = struct.pack('e', unpacked_float) # b'\x00\xfe' != b'\xff\xff' ``` IEEE `nan`s aren't unique, so this isn't _that_ surprising... However I found it curious that the same behavior is not exhibited for `float` (`f`) or `double` (`d`) format, where every original bit pattern I tested could be recovered from the unpacked `nan` object. Is this by design? Here's a quick `pytest` script that tests over a broad range of `nan`/`inf`/`-inf` cases for each encoding format. ```python # /// script # requires-python = ">=3.11" # dependencies = ["pytest"] # /// import struct import pytest # Floating Point Encodings Based on IEEE 754 per https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats # binary 16 (half precision) - 1 bit sign, 5 bit exponent, 11 bit significand # binary 32 (single precision) - 1 bit sign, 8 bit exponent, 23 bit significand # binary 64 (double precision) - 1 bit sign, 11 bit exponent, 52 bit significand MAX_TEST_CASES = 100000 # limit number of bit patterns being sampled so we aren't waiting too long @pytest.mark.parametrize(["precision_format", "precision", "exponent_bits"], [("f", 32, 8), ("d", 64, 11), ("e", 16, 5)]) @pytest.mark.parametrize("sign_bit", [0, 1]) @pytest.mark.parametrize("endianness", ["little", "big"]) def test_struct_floats(precision_format: str, precision: int, exponent_bits: int, sign_bit: int, endianness: str): significand_bits = precision - exponent_bits - 1 n_tests = min(MAX_TEST_CASES, 2**significand_bits) significand_patterns = [significand_bits * "0", significand_bits * "1"] + [ bin(i + 1)[2:] for i in range(1, 2**significand_bits, 2**significand_bits // n_tests) ] for i in range(n_tests): binary = str(sign_bit) + "1" * exponent_bits + significand_patterns[i] if endianness == "big": format = ">" + precision_format elif endianness == "little": format = "<" + precision_format else: raise NotImplementedError() test_bytes = int(binary, base=2).to_bytes(precision // 8, endianness) unpacked = struct.unpack(format, test_bytes) assert len(unpacked) == 1 repacked = struct.pack(format, unpacked[0]) assert ( repacked == test_bytes ), f"struct pack/unpack was not invertible for format {format} with raw value: {test_bytes} -> unpacks to {unpacked[0]}, repacks to {repacked}" if __name__ == "__main__": pytest.main([__file__]) ``` ![Image](https://github.com/user-attachments/assets/539eaa87-44da-421d-9bc0-bee81dc110ed) ### CPython versions tested on: 3.13, 3.11, 3.12 ### Operating systems tested on: Linux, Windows <!-- gh-linked-prs --> ### Linked PRs * gh-130452 * gh-133150 * gh-133155 * gh-133204 <!-- /gh-linked-prs -->
6157135a8d0bc2dbd5c24d1648d04a9c24a7d17e
922049b613d155ade4c4a8f83452767bea003a9f
python/cpython
python__cpython-130126
# We shouldn't lock to clear an object # Feature or enhancement ### Proposal: Currently we lock to clear the attributes of an object because we just re-use setting a managed dict to NULL. But if we haven't created a managed dictionary then there's no need to lock the object, it's no longer referenced externally. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130126 <!-- /gh-linked-prs -->
6c450f44c283c61d0e1ada05ead9524a1fe97962
69426fcee7fcecbe34be66d2c5b58b6d0ffe2809
python/cpython
python__cpython-130136
# We shouldn't use locking APIs when creating sets in bytecode # Feature or enhancement ### Proposal: Currently we hit a locking API for populating sets during comprehensions and set literals. We should use a lock-free API as the object isn't exposed yet. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130136 <!-- /gh-linked-prs -->
d9411ae3c2f6b59d97a0a16ad3dd148cc58ad943
7101cba6bf12639e277f7681b90a70c11368cabb
python/cpython
python__cpython-130310
# Pushing temporary, non-object pointers to the stack between micro-ops is counter-productive Currently, we allow micro-ops to push temporary non-object pointers to the stack to be consumed by the following micro-op. This has a number of disadvantages. We originally allowed this for a number of reasons, most of which are not true any more. The original advantages: * Allows more instructions to be handled in the JIT as micro-ops could only have one operand. Micro-ops can now have two operands, so this isn't true any more * Would allow simpler optimizations be removing guards and leaving actions. In fact, the pair of micro-ops that push then pop are often so tightly coupled that there are best optimized as a single unit. * It reduces code duplication, by allowing common patterns such as `PUSH_FRAME` to be re-used. This is still true, so we may still want to allow `PUSH_FRAME`. But since `PUSH_FRAME` needs special treatment anyway, there may be a better way to do this. The disadvantages: * It complicates the code generator * Having non-object pointers on the stack is fragile, e.g. https://github.com/python/cpython/issues/129432 <!-- gh-linked-prs --> ### Linked PRs * gh-130310 * gh-131493 <!-- /gh-linked-prs -->
54965f3fb25b381995a73b09d928c344bd2b86bd
ab11c097052757b79060c75dd4835c2431e752b7
python/cpython
python__cpython-130333
# Colorize tests fail on iOS Xcode 16.2 # Bug report ### Bug description: The iOS buildbot was recently updated to run on Sequoia, with Xcode 16.2 and an iOS 18.2 simulator. This has revealed a set of test failures that weren't occurring on Xcode 15.4 and iOS 17.2: The failures are all in the `test__colorize` tests: ``` test_colorized_detection_checks_for_environment_variables (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_environment_variables) ... test_colorized_detection_checks_for_environment_variables (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_environment_variables) (env={}, fallback=True) ... FAIL test_colorized_detection_checks_for_environment_variables (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_environment_variables) (env={'FORCE_COLOR': ''}, fallback=True) ... FAIL test_colorized_detection_checks_for_environment_variables (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_environment_variables) (env={'NO_COLOR': ''}, fallback=True) ... FAIL test_colorized_detection_checks_for_environment_variables (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_environment_variables) (env={'PYTHON_COLORS': 'x'}, fallback=True) ... FAIL test_colorized_detection_checks_for_environment_variables (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_environment_variables) (env={'PYTHON_COLORS': ''}, fallback=True) ... FAIL test_colorized_detection_checks_for_environment_variables (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_environment_variables) (env={'PYTHON_COLORS': '1'}, fallback=True) ... FAIL test_colorized_detection_checks_for_environment_variables (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_environment_variables) (env={'PYTHON_COLORS': '0'}, fallback=True) ... FAIL test_colorized_detection_checks_for_environment_variables (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_environment_variables) (env={'PYTHON_COLORS': 'x'}, fallback=True) ... FAIL test_colorized_detection_checks_for_environment_variables (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_environment_variables) (env={'PYTHON_COLORS': ''}, fallback=True) ... FAIL test_colorized_detection_checks_for_file (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_file) ... FAIL test_colorized_detection_checks_for_std_streams (test.test__colorize.TestColorizeFunction.test_colorized_detection_checks_for_std_streams) ... FAIL ``` Example failed run: https://buildbot.python.org/#/builders/1380/builds/2619 This is likely due to a conflict between the iOS testbed forcing `NO_COLOR`, because an iOS log stream doesn't support ANSI logging sequences - but it's not clear why this didn't manifest previously. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-130333 * gh-130334 <!-- /gh-linked-prs -->
1b070060c025a00d43566a6df65aa7631861d7af
ee337bea01beb3da6dccfe1b48db9a4c891b05a1
python/cpython
python__cpython-130388
# iOS testbed fails to start on completely clean Xcode install machine # Bug report ### Bug description: The iOS testbed contains tooling to tail the log of a simulator while a test suite runs. It identifies the simulator by generating an initial list of simulators; and then polling until that list increases by one entry. To do this, it uses the command `xcrun simctl --set testing list -j` However, on a complete clean development machine, there are no testing devices yet, and `xcrun simctl --set testing list -j` returns an error code of 1, rather than an empty list. Github Actions CI is one example of this configuration. A workaround is to manually create the `~/Library/Developer/XCTestDevices` folder. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-130388 * gh-130532 <!-- /gh-linked-prs -->
99088ab081279329b8362e1c24533fa0be303e6f
56e337d32b88630f2c35458231cd61929f1be6d4
python/cpython
python__cpython-130291
# random.sample raises "IndexError: pop from empty list" when both "population" and "counts" are empty # Bug report ### Bug description: I just encountered the situation where I used `random.sample` but both the `population` and `counts` arguments were empty (my algorithm had nothing left to choose from). So, basically this situation: ```python >>> random.sample([], 1, counts=[]) Traceback (most recent call last): File "<python-input-1>", line 1, in <module> random.sample([], 1, counts=[]) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ File "/path/to/lib/python3.14/random.py", line 424, in sample total = cum_counts.pop() IndexError: pop from empty list ``` Instead of the `IndexError`, I expected a `ValueError`, similar to the following situations: ```python >>> random.sample([], 1) Traceback (most recent call last): File "<python-input-2>", line 1, in <module> random.sample([], 1) ~~~~~~~~~~~~~^^^^^^^ File "/path/to/lib/python3.14/random.py", line 434, in sample raise ValueError("Sample larger than population or is negative") ValueError: Sample larger than population or is negative >>> >>> random.sample([1], 2, counts=[1]) Traceback (most recent call last): File "<python-input-3>", line 1, in <module> random.sample([1], 2, counts=[1]) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "/path/to/lib/python3.14/random.py", line 429, in sample selections = self.sample(range(total), k=k) File "/path/to/lib/python3.14/random.py", line 434, in sample raise ValueError("Sample larger than population or is negative") ValueError: Sample larger than population or is negative ``` [The docs](https://docs.python.org/3/library/random.html#random.sample) mention that > If the sample size is larger than the population size, a [ValueError](https://docs.python.org/3/library/exceptions.html#ValueError) is raised. In addition, I would expect the following to work: ```python >>> random.sample([], 0, counts=[]) Traceback (most recent call last): File "<python-input-4>", line 1, in <module> random.sample([], 0, counts=[]) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ File "/path/to/lib/python3.14/random.py", line 424, in sample total = cum_counts.pop() IndexError: pop from empty list ``` similar to how it works when `counts` is not specified: ```python >>> random.sample([], 0) [] ``` Not sure though what CPython's backwards-compatibility policy has to say here, since changing the exception type – or, in the second case, removing the exception altogether – might actually break someone's code... --- Tested with: ```lang-none Python 3.14.0a5 (main, Feb 12 2025, 14:51:40) [Clang 19.1.6 ] on linux cpython-3.14.0a5-linux-x86_64-gnu ``` ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130291 * gh-130416 * gh-130417 <!-- /gh-linked-prs -->
286c517db0fedf8d923d6f9620bcbbac4333880d
0c4248f88e279df3254d62b34dfa3204a92c56a0
python/cpython
python__cpython-130284
# docs: fix deprecated or broken examples in urllib.request documentation. # Documentation While working on the issue #130132 , I encountered with some examples and I can see the W3C document is outdated with some examples of `urllib.request.urlopen()` in Example of `urllib.request` These are following things I find which is outdated. - https://www.w3.org/International/O-charset - output content of `urllib.request.urlopen('http://www.python.org/')` Also there are other which also need to be fixed: ref. https://docs.python.org/3/library/urllib.request.html#examples There are many example in `urllib.request` documentation that need to be updated as they no longer works as expected. > In the following example, we are sending a data-stream to the stdin of a CGI and reading the data it returns to us. Note that this example will only work when the Python installation supports SSL. > Use of Basic HTTP Authentication: <!-- gh-linked-prs --> ### Linked PRs * gh-130284 * gh-131626 * gh-131627 <!-- /gh-linked-prs -->
fd459b115330b089da26a0555f45afced597942a
557d2d20d484a7b22da39cdb876f6312ab66d561
python/cpython
python__cpython-130318
# traceback.print_last behaving differently across python versions # Bug report ### Bug description: `traceback.print_last()` correctly prints the latest traceback for python 3.10.16 and 3.11.9, but it prints `NoneType: None` for 3.12.9 and 3.13.2 See also https://github.com/ipython/ipython/issues/14744, I originally thought it was an ipython issue ``` Python 3.10.16 (main, Feb 13 2025, 14:32:36) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 1/0 Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero >>> import traceback >>> traceback.print_last() Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero ``` ``` Python 3.11.9 (main, Feb 13 2025, 14:34:41) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 1/0 Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero >>> import traceback >>> traceback.print_last() Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero ``` ``` Python 3.12.9 (main, Feb 13 2025, 13:23:03) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 1/0 Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero >>> import traceback >>> traceback.print_last() NoneType: None ``` ``` Python 3.13.2 (main, Feb 13 2025, 11:10:27) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 1/0 Traceback (most recent call last): File "<python-input-0>", line 1, in <module> 1/0 ~^~ ZeroDivisionError: division by zero >>> import traceback >>> traceback.print_last() NoneType: None ``` ### CPython versions tested on: 3.10, 3.11, 3.12, 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130318 * gh-130325 * gh-130326 * gh-130329 * gh-130330 * gh-130331 * gh-130342 * gh-130344 * gh-130345 <!-- /gh-linked-prs -->
6c982aeb547528174f8bc843267f584d8b133d14
73801864d866c76ae26a120b9db9de21b08f8b50
python/cpython
python__cpython-130237
# Issues with Decimal and three-argument pow() # Crash report 1. Three-argument `pow()` with non-Decimal first argument does not work in the Python implementation. ```pycon >>> from decimal import Decimal >>> pow(10, Decimal(2), 7) Decimal('2') >>> from _pydecimal import Decimal >>> pow(10, Decimal(2), 7) Traceback (most recent call last): File "<python-input-3>", line 1, in <module> pow(10, Decimal(2), 7) ~~~^^^^^^^^^^^^^^^^^^^ TypeError: unsupported operand type(s) for ** or pow(): 'int', 'Decimal', 'int' ``` But it works in the C implementation. 2. Three-argument `pow()` with only Decimal third argument crashes in the C implementation. ```pycon >>> from decimal import Decimal >>> pow(10, 2, Decimal(7)) python: ./Modules/_decimal/_decimal.c:139: find_state_left_or_right: Assertion `mod != NULL' failed. Aborted (core dumped) ``` In the Python implementation it only raises TypeError, which is expected. <!-- gh-linked-prs --> ### Linked PRs * gh-130237 * gh-130246 * gh-130247 <!-- /gh-linked-prs -->
b93b7e566e5a4efe7f077af2083140e50bd2b08f
4374e1de87c54ba2291f49c2fa3a105bb6641ce6
python/cpython
python__cpython-130245
# Crash when accessing the `asyncio` module state in task deallocation # Crash report ### What happened? Cross posting from https://github.com/agronholm/anyio/issues/870. I noticed that with Python 3.14.0a5 (it doesn't happen in a4) anyio's tests for asyncio run successfully and only in the end the info about the core dumped is displayed. You can see it by running the minimal reproducer (cut out from one of the tests) or in the interactive asyncio repl. I suspect this is a regression in Python rather than an issue in anyio, but I couldn't figure out a reproducer without anyio code. ### How can we reproduce the bug? - With Python 3.14.0a5 installed (in the snippet I use debug build of Python, but it will produce similar information when using the ordinary one) run `python -m asyncio` ```pycon >>> import asyncio >>> from anyio import to_interpreter >>> from functools import partial >>> assert await to_interpreter.run_sync(partial(sorted, reverse=True), ["a", "b"]) == ["b", "a"] >>> exit ``` result: ``` exiting asyncio REPL... python3-debug: /builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Objects/typeobject.c:5262: PyType_GetModuleByDef: Assertion `mro != NULL' failed. ``` The underlying function `to_thread.run_sync()` seems to trigger the issue. Running this as `repr.py` produces the same outcome. I ran it in gdb with Python debuginfo data, I attach the result. ```python import asyncio, io, anyio async def repr(): stream = io.BytesIO(b"data") assert await anyio.to_thread.run_sync(stream.read) == b"data" asyncio.run(repr()) ``` <details><summary>gdb stack trace</summary> ``` Starting program: /usr/bin/python3-debug repr.py This GDB supports auto-downloading debuginfo from the following URLs: <https://debuginfod.fedoraproject.org/> Enable debuginfod for this session? (y or [n]) y Debuginfod has been enabled. To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit. Downloading separate debug info for system-supplied DSO at 0x7ffff7fc5000 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x7ffff61ff6c0 (LWP 47)] [Thread 0x7ffff61ff6c0 (LWP 47) exited] python3-debug: /builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Objects/typeobject.c:5262: PyType_GetModuleByDef: Assertion `mro != NULL' failed. Thread 1 "python3-debug" received signal SIGABRT, Aborted. Downloading source file /usr/src/debug/glibc-2.40.9000-37.fc43.x86_64/nptl/pthread_kill.c __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44 44 return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0; (gdb) bt #0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44 #1 0x00007ffff7480343 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:89 #2 0x00007ffff7426cbe in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007ffff740e6d6 in __GI_abort () at abort.c:73 #4 0x00007ffff740e639 in __assert_fail_base (fmt=<optimized out>, assertion=<optimized out>, file=<optimized out>, line=5262, function=<optimized out>) at assert.c:118 #5 0x00007ffff77a883a in PyType_GetModuleByDef (type=0x555555852ca0, def=0x7ffff6911000 <_asynciomodule>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/typeobject.c:5262 #6 0x00007ffff68fb050 in get_asyncio_state_by_def (self=<_asyncio.Task() at remote 0x7ffff624ce60>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Modules/_asynciomodule.c:204 #7 0x00007ffff6903144 in TaskObj_dealloc (self=<_asyncio.Task() at remote 0x7ffff624ce60>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Modules/_asynciomodule.c:3068 #8 0x00007ffff7760214 in _Py_Dealloc (op=<_asyncio.Task() at remote 0x7ffff624ce60>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/object.c:3009 #9 0x00007ffff7735568 in Py_DECREF ( filename=0x7ffff7c7b688 "/builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Include/refcount.h", lineno=502, op=<_asyncio.Task() at remote 0x7ffff624ce60>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Include/refcount.h:393 #10 0x00007ffff77355bd in Py_XDECREF (op=<_asyncio.Task() at remote 0x7ffff624ce60>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Include/refcount.h:502 #11 0x00007ffff77373b9 in dictkeys_decref (interp=0x7ffff7e0c510 <_PyRuntime+105072>, dk=0x7ffff62353f0, use_qsbr=false) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:460 #12 0x00007ffff773db30 in dict_dealloc ( self={'_default_interpreter_limiter': <unknown at remote 0x7ffff6274480>, '_available_workers': <collections.deque at remote 0x7ffff63c3250>, '_threadpool_idle_workers': <unknown at remote 0x7ffff63c3850>, '_threadpool_workers': <unknown at remote 0x7ffff6211a90>, '_root_task': <_asyncio.Task() at remote 0x7ffff624ce60>}) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:3266 #13 0x00007ffff7760214 in _Py_Dealloc ( op={'_default_interpreter_limiter': <unknown at remote 0x7ffff6274480>, '_available_workers': <collections.deque at remote 0x7ffff63c3250>, '_threadpool_idle_workers': <unknown at remote 0x7ffff63c3850>, '_threadpool_workers': <unknown at remote 0x7ffff6211a90>, '_root_task': <_asyncio.Task() at remote 0x7ffff624ce60>}) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/object.c:3009 #14 0x00007ffff7735568 in Py_DECREF ( filename=0x7ffff7c7b688 "/builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Include/refcount.h", lineno=502, op={'_default_interpreter_limiter': <unknown at remote 0x7ffff6274480>, '_available_workers': <collections.deque at remote 0x7ffff63c3250>, '_threadpool_idle_workers': <unknown at remote 0x7ffff63c3850>, '_threadpool_workers': <unknown at remote 0x7ffff6211a90>, '_root_task': <_asyncio.Task() at remote 0x7ffff624ce60>}) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Include/refcount.h:393 #15 0x00007ffff77355bd in Py_XDECREF ( op={'_default_interpreter_limiter': <unknown at remote 0x7ffff6274480>, '_available_workers': <collections.deque at remote 0x7ffff63c3250>, '_threadpool_idle_workers': <unknown at remote 0x7ffff63c3850>, '_threadpool_workers': <unknown at remote 0x7ffff6211a90>, '_root_task': <_asyncio.Task() at remote 0x7ffff624ce60>}) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Include/refcount.h:502 #16 0x00007ffff7737441 in dictkeys_decref (interp=0x7ffff7e0c510 <_PyRuntime+105072>, dk=0x7ffff626e2c0, use_qsbr=false) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:468 #17 0x00007ffff773db30 in dict_dealloc ( self={<unknown at remote 0x7ffff6270360>: {'_default_interpreter_limiter': <unknown at remote 0x7ffff6274480>, '_available_workers': <collections.deque at remote 0x7ffff63c3250>, '_threadpool_idle_workers': <unknown at remote 0x7ffff63c3850>, '_threadpool_workers': <unknown at remote 0x7ffff6211a90>, '_root_task': <_asyncio.Task() at remote 0x7ffff624ce60>}}) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:3266 #18 0x00007ffff7760214 in _Py_Dealloc ( op={<unknown at remote 0x7ffff6270360>: {'_default_interpreter_limiter': <unknown at remote 0x7ffff6274480>, '_avai--Type <RET> for more, q to quit, c to continue without paging--c lable_workers': <collections.deque at remote 0x7ffff63c3250>, '_threadpool_idle_workers': <unknown at remote 0x7ffff63c3850>, '_threadpool_workers': <unknown at remote 0x7ffff6211a90>, '_root_task': <_asyncio.Task() at remote 0x7ffff624ce60>}}) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/object.c:3009 #19 0x00007ffff7735568 in Py_DECREF ( filename=0x7ffff7c94de0 "/builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Objects/dictobject.c", lineno=7179, op={<unknown at remote 0x7ffff6270360>: {'_default_interpreter_limiter': <unknown at remote 0x7ffff6274480>, '_available_workers': <collections.deque at remote 0x7ffff63c3250>, '_threadpool_idle_workers': <unknown at remote 0x7ffff63c3850>, '_threadpool_workers': <unknown at remote 0x7ffff6211a90>, '_root_task': <_asyncio.Task() at remote 0x7ffff624ce60>}}) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Include/refcount.h:393 #20 0x00007ffff774551d in set_dict_inline_values (obj=<WeakKeyDictionary() at remote 0x7ffff6db2b00>, new_dict=0x0) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:7179 #21 0x00007ffff7745654 in set_or_clear_managed_dict (obj=<WeakKeyDictionary() at remote 0x7ffff6db2b00>, new_dict=0x0, clear=true) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:7313 #22 0x00007ffff77457d4 in PyObject_ClearManagedDict (obj=<WeakKeyDictionary() at remote 0x7ffff6db2b00>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:7351 #23 0x00007ffff77a2339 in subtype_dealloc (self=<WeakKeyDictionary() at remote 0x7ffff6db2b00>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/typeobject.c:2557 #24 0x00007ffff7760214 in _Py_Dealloc (op=<WeakKeyDictionary() at remote 0x7ffff6db2b00>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/object.c:3009 #25 0x00007ffff7735568 in Py_DECREF ( filename=0x7ffff7c7b688 "/builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Include/refcount.h", lineno=502, op=<WeakKeyDictionary() at remote 0x7ffff6db2b00>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Include/refcount.h:393 #26 0x00007ffff77355bd in Py_XDECREF (op=<WeakKeyDictionary() at remote 0x7ffff6db2b00>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Include/refcount.h:502 #27 0x00007ffff77373b9 in dictkeys_decref (interp=0x7ffff7e0c510 <_PyRuntime+105072>, dk=0x5555557888a0, use_qsbr=false) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:460 #28 0x00007ffff773cb85 in clear_lock_held (op={}) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:2865 #29 0x00007ffff773ccc4 in PyDict_Clear (op={}) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:2889 #30 0x00007ffff7740ea9 in dict_tp_clear (op={}) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Objects/dictobject.c:4608 #31 0x00007ffff792e0e5 in delete_garbage (tstate=0x7ffff7e432f0 <_PyRuntime+329808>, gcstate=0x7ffff7e0e1f8 <_PyRuntime+112472>, collectable=0x7fffffffde80, old=0x7ffff7e0e228 <_PyRuntime+112520>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Python/gc.c:1130 #32 0x00007ffff792f8cd in gc_collect_region (tstate=0x7ffff7e432f0 <_PyRuntime+329808>, from=0x7ffff7e0e228 <_PyRuntime+112520>, to=0x7ffff7e0e228 <_PyRuntime+112520>, stats=0x7fffffffdf40) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Python/gc.c:1745 #33 0x00007ffff792f62d in gc_collect_full (tstate=0x7ffff7e432f0 <_PyRuntime+329808>, stats=0x7fffffffdf40) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Python/gc.c:1665 #34 0x00007ffff79303fa in _PyGC_Collect (tstate=0x7ffff7e432f0 <_PyRuntime+329808>, generation=2, reason=_Py_GC_REASON_SHUTDOWN) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Python/gc.c:2026 #35 0x00007ffff7930501 in _PyGC_CollectNoFail (tstate=0x7ffff7e432f0 <_PyRuntime+329808>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Python/gc.c:2067 #36 0x00007ffff7a0e006 in finalize_modules (tstate=0x7ffff7e432f0 <_PyRuntime+329808>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Python/pylifecycle.c:1747 #37 0x00007ffff7a0e644 in _Py_Finalize (runtime=0x7ffff7df2aa0 <_PyRuntime>) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Python/pylifecycle.c:2078 #38 0x00007ffff7a0e706 in Py_FinalizeEx () at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Python/pylifecycle.c:2204 #39 0x00007ffff7a58351 in Py_RunMain () at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Modules/main.c:768 #40 0x00007ffff7a58422 in pymain_main (args=0x7fffffffe0a0) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Modules/main.c:796 #41 0x00007ffff7a584ea in Py_BytesMain (argc=2, argv=0x7fffffffe218) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Modules/main.c:820 #42 0x00005555555544bd in main (argc=2, argv=0x7fffffffe218) at /usr/src/debug/python3.14-3.14.0~a5-1.fc43.x86_64/Programs/python.c:15 ``` </details> ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130245 <!-- /gh-linked-prs -->
5f00501a940a0fb97870e70066fb301909320388
660f126f870535b6fa607e6d9cdd3cdbd9ed2cb1
python/cpython
python__cpython-130215
# Undocumented public C-API `PyEllipsis_Type` # Documentation `PyEllipsis_Type` is in the limited API and not documented. <!-- gh-linked-prs --> ### Linked PRs * gh-130215 * gh-130223 * gh-130224 <!-- /gh-linked-prs -->
fc8c99a8ce483db23fa624592457e350e99193f6
f55d0b66be225e4a7fe6d8c50e8b49fd37b4ecc9
python/cpython
python__cpython-130281
# `_PyObject_ResurrectEnd` may deallocate object in the "resurrection" case # Bug report See https://github.com/python/cpython/issues/130163#issuecomment-2661465164 for reproducer. > Yeah, I think that's another bug with `_PyObject_ResurrectEnd`. In the resurrection case, the object may still be deallocated. In particular, `_Py_brc_queue_object()` may immediately free the object or lead to it being freed by another thread. The calls below `_PyObject_ResurrectEnd()` are not safe: > > https://github.com/python/cpython/blob/655fc8a0fce3396fc1af3f7bc8f5c94ca8ec377d/Objects/object.c#L594-L604 > > We either need to ensure that the object remains alive after `_PyObject_ResurrectEnd()` returns `1`, or rearrange the resurrection code. _Originally posted by @colesbury in [#130163](https://github.com/python/cpython/issues/130163#issuecomment-2661552094)_ I am not yet sure how we want to fix this. <!-- gh-linked-prs --> ### Linked PRs * gh-130281 <!-- /gh-linked-prs -->
f963239ff1f986742d4c6bab2ab7b73f5a4047f6
c5f925c8c948736bd64652918b4e0186b91abbb5
python/cpython
python__cpython-130196
# pygettext: Remove unused option `-a/--extract-all` It has never been implemented. PR soon @tomasr8 <!-- gh-linked-prs --> ### Linked PRs * gh-130196 * gh-130254 <!-- /gh-linked-prs -->
4374e1de87c54ba2291f49c2fa3a105bb6641ce6
99d965635ae2ac4bffdc318ee05b96c59262d165
python/cpython
python__cpython-130208
# Increase test coverage of `gettext.c2py` `gettext.c2py` is not fully covered: ![Image](https://github.com/user-attachments/assets/ef1f2a55-10db-4269-8b1e-7bbc73c43164) (`_parse` is called by `c2py`) We need to cover negation (e.g. `!n`) and an invalid ternary (e.g. `n ? 1 2`) <!-- gh-linked-prs --> ### Linked PRs * gh-130208 * gh-130217 * gh-130218 <!-- /gh-linked-prs -->
fb2d325725dcc881868b576b9d0d9f4bf7f24fe0
422f8e9e02e68d45aee3846751a003a70fca13b6
python/cpython
python__cpython-130186
# Some tests are skipped in `test_functools` # Bug report ### Bug description: `TestCache` is not used by any other test class in the module. I'm guessing it was intended to be used as `TestLRU` but it currently does not run: https://github.com/python/cpython/blob/9837c2a21457e4eacabf606c44ec42d1962f11f1/Lib/test/test_functools.py#L1474-L1476 ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130186 * gh-130188 * gh-130189 <!-- /gh-linked-prs -->
73d03005b028eb6e4d1a643f3ca7a1f5ff2040fc
c9b1bf302ce67031e0309a9b0ea55ecdd68ed682
python/cpython
python__cpython-130180
# Missing `Py_CLEAR/Py_VISIT` calls for `Unpickler.persistent_load_attr` and `Pickler.persistent_id_attr` # Bug report ### Bug description: I found that `Unpickler.persistent_load_attr` and `Pickler.persistent_id_attr` can be set, but never clear. However, I didn't find any uses of them. Another issue, I found that `PDATA_APPEND` and `PDATA_PUSH` may lead to memory leaks if `PyErr_NoMemory` is raised. What do we do about resources when this happens? I've seen resources get cleared, and sometimes they don't. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130180 * gh-130190 <!-- /gh-linked-prs -->
e7f00cd14f6a0c0dee6e733ac3e2c5d92e0809bb
56495f81fc7205b572173a03d418e0f9291f9eea
python/cpython
python__cpython-130178
# Some tests are skipped in `test_gettext` # Bug report ### Bug description: `PluralFormsInternalTestCase` does not inherit from `unittest.TestCase` so the test is not picked up: https://github.com/python/cpython/blob/9837c2a21457e4eacabf606c44ec42d1962f11f1/Lib/test/test_gettext.py#L405-L407 ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130178 * gh-130183 * gh-130184 <!-- /gh-linked-prs -->
2e8044a4f74f5fc19e5249139c171403aff0118d
361083b84b0db975058b2d1f50dcbfd36f072caf
python/cpython
python__cpython-130174
# Possibly unnumbered list missing in Doc/c-api/function.rst # Documentation PyFunction_WatchEvent at c-api/function.rst has in the source file what seems to be a unnumbered list, but the built documentation has everything in a single line. Should it be formatted as a unnumbered list instead? https://github.com/python/cpython/blob/798f8d3ea9f54ee80a684bff74f67ee7d99e35c2/Doc/c-api/function.rst?plain=1#L146-L155 ![Image](https://github.com/user-attachments/assets/269319f3-d469-427d-8a8c-3609f6cf38cb) <!-- gh-linked-prs --> ### Linked PRs * gh-130174 * gh-130175 * gh-130176 <!-- /gh-linked-prs -->
9837c2a21457e4eacabf606c44ec42d1962f11f1
798f8d3ea9f54ee80a684bff74f67ee7d99e35c2
python/cpython
python__cpython-130192
# Signature.bind allows certain positional-only parameters as keywords # Bug report ### Bug description: Prior to 3.13, the following code correctly raised a `TypeError` (I've tested 3.8-3.12, but see the last paragraph below): ```python def fun(x, /, **kwargs): pass import inspect sig = inspect.signature(fun) sig.bind(x=1) ``` In 3.13, the binding succeeds even though the positional-only parameter was passed as a keyword argument (of course, `fun(x=1)` fails with a `TypeError`). As far as I can tell this bug hasn't been previously reported, although issue #107831 reports `inspect.getcallargs` as having the same problem (prior to 3.13, unlike this bug). I'm guessing the bug was introduced by #103404. If I try a version of 3.12 containing that patch (rather than the older versions I had installed previously), e.g. 3.12.9, it also exhibits the bug. It's possible that fixing the case where the positional-only parameter has a default value accidentally broke this case. Mentioning @jacobtylerwalls as the author of that PR in case they would like to take a look. Thanks! ### CPython versions tested on: 3.13 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-130192 * gh-130271 * gh-132259 <!-- /gh-linked-prs -->
dab456dcefd886bde44eb204dc6f1b2f14de0e9d
01ba7df49966eaf14f44962a77898840c70dda96
python/cpython
python__cpython-130165
# unaligned numbered list text and extra paragraph in collections.abc # Documentation [collections.abc](https://docs.python.org/3/library/collections.abc.html) has an almost numbered list in the beginning of the doc, but it is not correctly indented as such. This causes the text to not be rendered with indentation as numbered list and the translation won't be applied, so that string will be in English in the built doc. While simply add three spaces to align would fix it, there is the problem that the item 2 and item 3 have an extra paragraph which won't be included in the numbered list if will fix the indentation. https://github.com/python/cpython/blob/c26bed1160978fe8b1844878b8123778e47870c6/Doc/library/collections.abc.rst?plain=1#L30-L105 <!-- gh-linked-prs --> ### Linked PRs * gh-130165 * gh-130437 * gh-130438 <!-- /gh-linked-prs -->
8e96adf4532943360f09df04cd7d3a5d35f61a24
38642bff139bde5c0118bc75fda25badc76b85fc
python/cpython
python__cpython-129954
# match: confusion regarding `_` in match statements # Documentation https://docs.python.org/3.13/tutorial/controlflow.html#tut-match makes it look like `_` is not executed when no other branch is executed <!-- gh-linked-prs --> ### Linked PRs * gh-129954 <!-- /gh-linked-prs -->
1b5db5adfec10d90cf5c7abd6817452be4f0b909
ba05a4ebcb67506b4e6d65ea11e78d06f57dc23b
python/cpython
python__cpython-130152
# Reference leaks in `_hashlib.hmac_new` and `_hashlib.hmac_digest` # Bug report ### Bug description: The following leaks: ```py def test_leak1(self): import _hashlib self.assertRaises(TypeError, _hashlib.hmac_new, b"key", 1, "sha256") ``` The issue is in `_hashlib_hmac_new_impl`: ```c self = PyObject_New(HMACobject, type); ... if ((msg_obj != NULL) && (msg_obj != Py_None)) { if (!_hmac_update(self, msg_obj)) goto error; } return (PyObject*)self; error: if (ctx) HMAC_CTX_free(ctx); if (self) PyObject_Free(self); return NULL; ``` More precisely, the issue is that we are only calling `PyObject_Free(self)` and we are not decrefing the type. So we need to call `Py_XDECREF(self);` instead and free `ctx` separately if `self` has not already been allocated. Note that the HMAC context is still cleared so we should not leak anything sensitive. There is also a missing `HMAC_CTX_free` call in `_hmac_digest`, if the copy of the HMAC context fails. Again, there shouldn't be a security issue as the temporary context should still not be initialized on failure (and the secret key is not stored within, hopefully). ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130152 * gh-130491 * gh-130539 <!-- /gh-linked-prs -->
071820113f11b8f6a21f98652d0840e10268114c
72ea3c030a81262af64ebcae2e83ce2ff529bcef
python/cpython
python__cpython-130150
# Refactor tests for HMAC The tests for HMAC are organized in such a way that makes the adoption of HACL* HMAC harder. More precisely, it'll be a bit harder to test the OpenSSL *and* the HACL* implementation of HMAC (for instance, some tests may or may not work with HACL* as they only support a subset of the hash functions supported by OpenSSL). I am suggesting a way to make the test interface more generic using mixin classes. For instance, we have multiple ways of creating a HMAC object. It can be through `hmac.HMAC` or through `hmac.new` or through `_hashlib.hmac_new`. While `hmac.new` and `hmac.HMAC` are identical, `_hashlib.hmac_new` is different in the sense that the signature is different as well (and that the objects being returned are also different; they are not instances of `hmac.HMAC` but instances of `_hashlib.HMAC`, though they implement the same interface). Now, once we add HACL* implementation, the interface will be similar to the Python implementation of HMAC and thus we need to test them both. Currently, it's hard to switch from the Python module implementation to the C implementation. <!-- gh-linked-prs --> ### Linked PRs * gh-130150 * gh-130788 * gh-131318 <!-- /gh-linked-prs -->
8f11af45de68459d9d4051812aa5ddaf6a98dcb2
a105f990199f99a352efd481ac039604feceaab5
python/cpython
python__cpython-130146
# loop.run_forever can remove running loop if already running Reproducer: ```py import asyncio async def main(): loop = asyncio.new_event_loop() try: loop.run_forever() except RuntimeError: pass print(asyncio.get_running_loop()) asyncio.run(main()) ``` Output: ```console cpython on  main [$?] via C v13.3.0-gcc via 🐍 v3.12.3 ❯ ./python main.py Traceback (most recent call last): File "/home/realkumaraditya/cpython/main.py", line 15, in <module> asyncio.run(main()) ~~~~~~~~~~~^^^^^^^^ File "/home/realkumaraditya/cpython/Lib/asyncio/runners.py", line 204, in run return runner.run(main) ~~~~~~~~~~^^^^^^ File "/home/realkumaraditya/cpython/Lib/asyncio/runners.py", line 127, in run return self._loop.run_until_complete(task) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "/home/realkumaraditya/cpython/Lib/asyncio/base_events.py", line 719, in run_until_complete return future.result() ~~~~~~~~~~~~~^^ File "/home/realkumaraditya/cpython/main.py", line 11, in main print(asyncio.get_running_loop()) ~~~~~~~~~~~~~~~~~~~~~~~~^^ RuntimeError: no running event loop /home/realkumaraditya/cpython/Lib/asyncio/base_events.py:758: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False> ``` <!-- gh-linked-prs --> ### Linked PRs * gh-130146 * gh-130147 <!-- /gh-linked-prs -->
a545749b0e6c56cab853c5c8df3c199b9707994f
a05433f24a6e1c6d2fbcc82b7a372c376a230897
python/cpython
python__cpython-130140
# ast.parse() without optimize=True doesn't error on invalid AST type ``` >>> ast.parse(ast.Constant(42)) Constant(value=42, kind=None) >>> ast.parse(ast.Constant(42), optimize=True) Traceback (most recent call last): File "<python-input-4>", line 1, in <module> ast.parse(ast.Constant(42), optimize=True) ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.14/ast.py", line 53, in parse return compile(source, filename, mode, flags, _feature_version=feature_version, optimize=optimize) TypeError: expected Module node, got Constant ``` (This came up while implementing PEP 765 https://github.com/python/cpython/issues/130080). <!-- gh-linked-prs --> ### Linked PRs * gh-130140 <!-- /gh-linked-prs -->
c9b1bf302ce67031e0309a9b0ea55ecdd68ed682
2e8044a4f74f5fc19e5249139c171403aff0118d
python/cpython
python__cpython-130280
# docs: add an explicit `close()` call to `urlopen` examples without `with` # Documentation The [documentation](https://docs.python.org/3/library/urllib.request.html#examples) for `urllib.request` uses `urlopen()` 3 times without either `with` or manual closing. Although technically possible, this is not recommended. > It is also possible to achieve the same result without using the [context manager](https://docs.python.org/3/glossary.html#term-context-manager) approach. > ``` > >>> import urllib.request > >>> f = urllib.request.urlopen('http://www.python.org/') > >>> print(f.read(100).decode('utf-8')) > ``` > ... > Use of Basic HTTP Authentication: > ``` > urllib.request.urlopen('http://www.example.com/login.html') > ``` > ... > Adding HTTP headers: > ``` > r = urllib.request.urlopen(req) > ``` This is a follow-up from [ruff #13683](https://github.com/astral-sh/ruff/issues/13683). <!-- gh-linked-prs --> ### Linked PRs * gh-130280 * gh-131394 * gh-131395 <!-- /gh-linked-prs -->
77d2fd441320ca365c34e21c475d3878f3d5d833
3f50f96586d46497e4d9de065c4424fe2d72508e
python/cpython
python__cpython-130324
# Clarify the meaning `dataclasses.field(..., hash=False)` See https://discuss.python.org/t/unclear-docs-for-dataclasses-field/80716. Currently the docs are: > hash: This can be a bool or None. If true, this field is included in the generated [\_\_hash\_\_()](https://docs.python.org/3/reference/datamodel.html#object.__hash__) method. If None (the default), use the value of compare: this would normally be the expected behavior. A field should be considered in the hash if it’s used for comparisons. Setting this value to anything other than None is discouraged. We can change it to ```diff hash: This can be a bool or None. If true, this field is included in the generated :meth:`~object.__hash__` method. +If false, this field is excluded from the generated :meth:`~object.__hash__` method. If :const:`None` (the default), use the value of compare: this would normally be the expected behavior. ``` <!-- gh-linked-prs --> ### Linked PRs * gh-130324 * gh-130336 * gh-130337 <!-- /gh-linked-prs -->
47ace539950fb675d5968736348f0d724ba199f0
1b070060c025a00d43566a6df65aa7631861d7af
python/cpython
python__cpython-130124
# __new__ tp-wrapper can be deferred on free-threaded builds # Feature or enhancement ### Proposal: `__new__`'s wrapper is small, doesn't hold onto other things except the circular reference between it and the type, meaning the GC reclaims it anyways. We may as well defer it and be able to load cached values. ### 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-130124 <!-- /gh-linked-prs -->
5a586c3e81ab53bb1f6c20a4c80b4eb69d429410
e65e9f90626a4c62da4d3500044f354b51e51dbb
python/cpython
python__cpython-130119
# `typing.Annotated` does not flatten through `typing.TypeAliasType` # Bug report ### Bug description: As described in the [documentation](https://docs.python.org/3/library/typing.html#typing.Annotated), nested `Annotated` types are supposed to be flattened. This works well with legacy type aliases but not with the `type` statement introduced in python 3.12: ```python from typing import Annotated, TypeAlias print(Annotated[Annotated[int, "A"], "B"] == Annotated[int, "A", "B"]) # True A: TypeAlias = Annotated[int, "A"] print(Annotated[A, "B"] == Annotated[int, "A", "B"]) # True type A = Annotated[int, "A"] print(Annotated[A, "B"] == Annotated[int, "A", "B"]) # False ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-130119 * gh-133488 <!-- /gh-linked-prs -->
b936ccdb6f6bd11250b4e638b6fa2c239907ca58
529012e26fc43d9b101b034d372b443a24bdf2af
python/cpython
python__cpython-130391
# Active thread list may be inaccurate due to data type mismatch # Bug report ### Bug description: https://github.com/python/cpython/commit/0e9c364f4ac18a2237bdbac702b96bcf8ef9cb09 changed `thread_get_ident` to convert a `unsigned long long` vs the previous `unsigned long`. ```c static PyObject * thread_get_ident(PyObject *self, PyObject *Py_UNUSED(ignored)) { PyThread_ident_t ident = PyThread_get_thread_ident_ex(); // <-- ULL if (ident == PYTHREAD_INVALID_THREAD_ID) { PyErr_SetString(ThreadError, "no current thread ident"); return NULL; } return PyLong_FromUnsignedLongLong(ident); } ``` However, after https://github.com/python/cpython/pull/114839 commit https://github.com/python/cpython/pull/114839/commits/76bde036984431df51f2c432b4cd078e6a9ccc58 `MainThread` is now a special case because it doesn't use `self._set_ident()`: ```python class _MainThread(Thread): def __init__(self): Thread.__init__(self, name="MainThread", daemon=False) self._started.set() self._ident = _get_main_thread_ident() self._handle = _make_thread_handle(self._ident) if _HAVE_THREAD_NATIVE_ID: self._set_native_id() with _active_limbo_lock: _active[self._ident] = self ``` It inserts an identifier from a special function which is always the clipped `unsigned long` from the runtime struct into the active thread list. ```c static PyObject * thread__get_main_thread_ident(PyObject *module, PyObject *Py_UNUSED(ignored)) { return PyLong_FromUnsignedLongLong(_PyRuntime.main_thread); } ``` ```c /* Platform-specific identifier and PyThreadState, respectively, for the main thread in the main interpreter. */ unsigned long main_thread; ``` ```c // Set it to the ID of the main thread of the main interpreter. runtime->main_thread = PyThread_get_thread_ident(); ``` Because of this, on some platforms/libc implementations, we can observe a failure to look up the current thread because of the mismatch between clipped UL value vs the expected ULL value: ``` >>> import threading >>> ct = threading.current_thread() >>> ct <_DummyThread(Dummy-1, started daemon 18446744072483979068)> >>> hex(ct.ident) '0xffffffffb6f33f3c' >>> main = threading.main_thread() >>> hex(main.ident) '0xb6f33f3c' >>> main._set_ident() >>> hex(main.ident) '0xffffffffb6f33f3c' ``` ``` def current_thread(): """Return the current Thread object, corresponding to the caller's thread of control. If the caller's thread of control was not created through the threading module, a dummy thread object with limited functionality is returned. """ try: return _active[get_ident()] except KeyError: return _DummyThread() ``` Should `main_thread` to be a `PyThread_ident_t` ? or should `MainThread` continue to call `_set_ident()`? ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130391 * gh-132089 <!-- /gh-linked-prs -->
72123063ddee84bb2c9d591a23f420997e35af5a
345baa77ba2ce3b8ea8f2fad84754e5cc0b10938
python/cpython
python__cpython-130107
# Small typo in https://docs.python.org/3/library/unittest.mock.html#where-to-patch https://docs.python.org/3/library/unittest.mock.html#where-to-patch has the text "which we will have to do then it imports" which should be "which we will have to do when it imports" (i.e. `s/then/when/`). The source for this is https://github.com/python/cpython/blob/3bd3e09588bfde7edba78c55794a0e28e2d21ea5/Doc/library/unittest.mock.rst?plain=1#L2010-L2011 <!-- gh-linked-prs --> ### Linked PRs * gh-130107 * gh-130143 * gh-130144 <!-- /gh-linked-prs -->
d2e60d8e598b622573b68b80b4fbf98c021dd087
39cd9728a6770d8fe7937c57385cda5c2e25a223
python/cpython
python__cpython-130251
# Inconsistent behavior of ternary pow() for Python classes and C extension types # Bug report ### Bug description: Consider an example: ```pycon Python 3.13.1 (tags/v3.13.1:0671451779, Dec 4 2024, 07:55:26) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import example >>> pow(42, example.xxx(), example.xxx()) # (1) called power 123 >>> pow(42, example.xxx()) called power 123 >>> class A: ... def __pow__(self, other, mod=None): ... print("__pow__") ... return 123 ... def __rpow__(self, other, mod=None): ... print("__rpow__") ... return 321 ... >>> pow(42, A(), A()) # (2) Traceback (most recent call last): File "<python-input-4>", line 1, in <module> pow(42, A(), A()) ~~~^^^^^^^^^^^^^^ TypeError: unsupported operand type(s) for ** or pow(): 'int', 'A', 'A' >>> pow(42, A()) __rpow__ 321 ``` In presence of the mod argument, C extension type (1) behave differently than the pure-Python analog (2). That looks as a bug. There is no documentation anywhere that explains how any of this is supposed to work so it’s hard to say that an alternative Python implementation like PyPy is doing anything incorrect or not. Third-party extensions (like gmpy2) already uses (1) to do things like `pow(int, gmpy2.mpz, gmpy2.mpz)` - work. Unfortunately, it's not possible to implement a pure-Python class like gmpy2.mpz, that able to do this. <details> <summary>example.c</summary> ```c /* example.c */ #define PY_SSIZE_T_CLEAN #include <Python.h> PyTypeObject XXX_Type; static PyObject * new(PyTypeObject *type, PyObject *args, PyObject *keywds) { return PyObject_New(PyObject, &XXX_Type); } static PyObject * power(PyObject *self, PyObject *other, PyObject *module) { printf("called power\n"); return PyLong_FromLong(123); } static PyNumberMethods xxx_as_number = { .nb_power = power, }; PyTypeObject XXX_Type = { PyVarObject_HEAD_INIT(NULL, 0) .tp_name = "xxx", .tp_new = new, .tp_as_number = &xxx_as_number, }; static struct PyModuleDef ex_module = { PyModuleDef_HEAD_INIT, "example", "Test module.", -1, NULL, }; PyMODINIT_FUNC PyInit_example(void) { PyObject *m = PyModule_Create(&ex_module); if (PyModule_AddType(m, &XXX_Type) < 0) { return -1; } return m; } ``` </details> PS: This was discussed before in https://discuss.python.org/t/35185. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130251 <!-- /gh-linked-prs -->
62ff86fa55c903a8362a64ecc363d8443aff2d07
72da4a445867648ee668bfc68a9bb659dfebe658
python/cpython
python__cpython-130101
# Parallel import of modules causes a ModuleNotFoundError # Bug report ### Bug description: Using the free-threading build parallel import of modules causes a `ModuleNotFoundError`. The module that cannot be found can differ. A minimal reproducer: ```python import sys from threading import Thread, Barrier from importlib import import_module, reload import time # Setup threads t0 = time.perf_counter() number_of_threads = 8 barrier = Barrier(number_of_threads) pmods = [] def work(ii): # Method doing the actual import barrier.wait() while True: try: m = pmods.pop() mod = import_module(m) # print(f' {ii}: {m} done') except IndexError: return worker_threads = [] for ii in range(number_of_threads): worker_threads.append(Thread(target=work, args=[ii])) dt = time.perf_counter() - t0 print(f"setup threads {dt*1e3:.2f}") def parallel_import(modules: list[str]): global pmods pmods += modules for t in worker_threads: t.start() for t in worker_threads: t.join() def seq_import(modules: list[str]): for m in modules: mod = import_module(m) import_method = seq_import import_method = parallel_import mods = [ "abc", "functools", "weakref", "linecache", "glob", "annotationlib", "argparse", "fnmatch", "itertools", "operator", "string", "re", "collections", "sqlite3", "pathlib", "urllib", "typing", "csv", "uuid", ] mods += [ "setuptools", "sympy", "django", "boto3", ] # these are some packages that need to be installed. without these the reproduction is the issue is much harder t0 = time.perf_counter() import_method(mods) dt = time.perf_counter() - t0 print(f"{import_method.__name__} {dt*1e3:.2f}") ``` Note: this script fails on my system about 1 in 4 times. Changing the modules imported (or the order, or the number of threads) can effect this. Modules that have given issues: `collections.abs`, `glob`, `sympy`, `django.utils.regex_helper`. This suggests it is a general issue, and not a particular package. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-130101 <!-- /gh-linked-prs -->
857bdba0ac66ed7963e9fca45ab1a5f7a32b4bfb
8207454bc00db8efa0e05c93381ecc8e3efc86a7
python/cpython
python__cpython-130092
# Data race in `PyThread_tss_delete` and `_PyThreadState_Attach` # Bug report There are a few data races during Python shutdown. This report involves thread-local variables using `Py_tss_t`. It can be reproduced sometimes by running `test_threading.test_import_from_another_thread` with TSAN repeatedly. ``` WARNING: ThreadSanitizer: data race (pid=19107) Write of size 4 at 0x55f728ab09f8 by main thread: #0 PyThread_tss_delete /home/runner/work/cpython/cpython/Python/thread_pthread.h:974:26 (python+0x61de2c) (BuildId: 4fc02961f60c9c3851edd7ecf2a252cdf887e381) #1 tstate_tss_fini /home/runner/work/cpython/cpython/Python/pystate.c:[13](https://github.com/python/cpython/actions/runs/13313503854/job/37181762988#step:14:14)9:5 (python+0x5e82bf) (BuildId: 4fc02961f60c9c3851edd7ecf2a252cdf887e381) #2 _PyRuntimeState_Fini /home/runner/work/cpython/cpython/Python/pystate.c:489:9 (python+0x5e82bf) #3 _PyRuntime_Finalize /home/runner/work/cpython/cpython/Python/pylifecycle.c:[14](https://github.com/python/cpython/actions/runs/13313503854/job/37181762988#step:14:15)1:5 (python+0x5c186d) (BuildId: 4fc02961f60c9c3851edd7ecf2a252cdf887e381) #4 _Py_Finalize /home/runner/work/cpython/cpython/Python/pylifecycle.c:2197:5 (python+0x5c186d) ... Previous read of size 4 at 0x55f728ab09f8 by thread T1: #0 PyThread_tss_is_created /home/runner/work/cpython/cpython/Python/thread.c:208:17 (python+0x61e43e) (BuildId: 4fc02961f60c9c3851edd7ecf2a252cdf887e381) #1 tstate_tss_initialized /home/runner/work/cpython/cpython/Python/pystate.c:125:12 (python+0x5edc6d) (BuildId: 4fc02961f60c9c3851edd7ecf2a252cdf887e381) #2 tstate_tss_get /home/runner/work/cpython/cpython/Python/pystate.c:145:5 (python+0x5edc6d) #3 tstate_activate /home/runner/work/cpython/cpython/Python/pystate.c:2010:5 (python+0x5edc6d) #4 _PyThreadState_Attach /home/runner/work/cpython/cpython/Python/pystate.c:2093:9 (python+0x5edc6d) #5 _Py_HandlePending /home/runner/work/cpython/cpython/Python/ceval_gil.c:1263:9 (python+0x5729e8) (BuildId: 4fc02961f60c9c3851edd7ecf2a252cdf887e381) #6 _PyEval_EvalFrameDefault /home/runner/work/cpython/cpython/Python/generated_cases.c.h:1431:31 (python+0x4c21a7) (BuildId: 4fc02961f60c9c3851edd7ecf2a252cdf887e381) ... ``` The problem is that we are reading `gilstate_tss_get((tstate->interp->runtime))` in an assertion, but that thread local variable is getting deleted concurrently by the thread calling `_PyRuntime_Finalize`. https://github.com/python/cpython/blob/07f5e33f2eed50984d7a60b48bb3136d93a59dd6/Python/pystate.c#L2010-L2011 https://github.com/python/cpython/blob/07f5e33f2eed50984d7a60b48bb3136d93a59dd6/Python/pystate.c#L2088-L2097 The default build doesn't have this problem because the thread T1 hangs earlier in the `_PyEval_AcquireLock()` call. In the free threaded build, the hang will occur later in `tstate_wait_attach()`. See also: * https://github.com/python/cpython/actions/runs/13313503854/job/37181762988 * https://github.com/python/cpython/issues/129266#issuecomment-2647234146 * https://discuss.python.org/t/flaky-thread-sanitizer-tests/80374/3 <!-- gh-linked-prs --> ### Linked PRs * gh-130092 <!-- /gh-linked-prs -->
7aeaa5af2c32f1f87b59f36f89e19284e24b26b9
e06bebb87e1b33f7251196e1ddb566f528c3fc98
python/cpython
python__cpython-129907
# Support PGO for clang-cl # Feature or enhancement ### Proposal: Support PGO (profile guided optimization) for clang-cl on Windows using a similar approach as done in the Linux makefiles for clang. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: Discussion has started in the PR https://github.com/python/cpython/pull/129907 while being draft. <!-- gh-linked-prs --> ### Linked PRs * gh-129907 * gh-131005 <!-- /gh-linked-prs --> 64bit pyperformance results on my Windows 10 PC (dusty i5-4570 CPU) run with `--fast --affinity 0` for commit https://github.com/python/cpython/pull/129907/commits/9db1a297d95574cc3114854c8c427736d9521917 with - Microsoft Visual Studio 2022 17.13.0 Preview 5.0 which can do PGO again (https://github.com/python/cpython/issues/129244) - which ships with clang-cl 19.1.1 | Benchmark | msvc.release.9db1a297d9 | clang.release.9db1a297d9 | msvc.pgo.9db1a297d9 | clang.pgo.9db1a297d9 | |----------------------------------|-------------------------|--------------------------|------------------------|------------------------| | Geometric mean | (ref) | 1.27x faster | 1.28x faster | 1.47x faster | | Benchmark | msvc.release.9db1a297d9 | clang.release.9db1a297d9 | |----------------------------------|-------------------------|--------------------------| | Geometric mean | (ref) | 1.27x faster | clang 18.1.8 is faster than 19.1.1, and 20.1.0.rc2 with tailcalling is the fastest: | Benchmark | msvc.pgo.9db1a297d9 | clang.pgo.18.1.8.9db1a297d9 | clang.pgo.9db1a297d9 | clang.pgo.tc.20.1.0.rc2.9db1a297d9 | |-----------------|---------------------|-----------------------------|------------------------|------------------------------------| | Geometric mean | (ref) | 1.19x faster | 1.15x faster | 1.25x faster | <details><summary>Details</summary> <p> Benchmarks with tag 'apps': | Benchmark | msvc.release.9db1a297d9 | clang.release.9db1a297d9 | msvc.pgo.9db1a297d9 | clang.pgo.9db1a297d9 | |----------------|-------------------------|--------------------------|------------------------|------------------------| | 2to3 | 586 ms | 491 ms: 1.19x faster | 462 ms: 1.27x faster | 426 ms: 1.38x faster | | docutils | 4.27 sec | 3.75 sec: 1.14x faster | 3.50 sec: 1.22x faster | 3.31 sec: 1.29x faster | | html5lib | 104 ms | 81.6 ms: 1.28x faster | 77.9 ms: 1.34x faster | 74.5 ms: 1.40x faster | | Geometric mean | (ref) | 1.20x faster | 1.28x faster | 1.35x faster | Benchmarks with tag 'asyncio': | Benchmark | msvc.release.9db1a297d9 | clang.release.9db1a297d9 | msvc.pgo.9db1a297d9 | clang.pgo.9db1a297d9 | |----------------------------------|-------------------------|--------------------------|----------------------|----------------------| | async_tree_none | 511 ms | 383 ms: 1.33x faster | 394 ms: 1.30x faster | 357 ms: 1.43x faster | | async_tree_cpu_io_mixed | 933 ms | 805 ms: 1.16x faster | 749 ms: 1.25x faster | 697 ms: 1.34x faster | | async_tree_cpu_io_mixed_tg | 891 ms | 776 ms: 1.15x faster | 716 ms: 1.24x faster | 665 ms: 1.34x faster | | async_tree_eager | 209 ms | 153 ms: 1.37x faster | 160 ms: 1.31x faster | 133 ms: 1.57x faster | | async_tree_eager_cpu_io_mixed | 656 ms | 630 ms: 1.04x faster | 567 ms: 1.16x faster | 535 ms: 1.23x faster | | async_tree_eager_cpu_io_mixed_tg | 830 ms | 741 ms: 1.12x faster | 681 ms: 1.22x faster | 646 ms: 1.28x faster | | async_tree_eager_io | 1.12 sec | 870 ms: 1.29x faster | 874 ms: 1.28x faster | 817 ms: 1.37x faster | | async_tree_eager_io_tg | 1.12 sec | 890 ms: 1.26x faster | 898 ms: 1.25x faster | 840 ms: 1.33x faster | | async_tree_eager_memoization | 393 ms | 304 ms: 1.29x faster | 304 ms: 1.29x faster | 281 ms: 1.40x faster | | async_tree_eager_memoization_tg | 546 ms | 420 ms: 1.30x faster | 427 ms: 1.28x faster | 397 ms: 1.37x faster | | async_tree_eager_tg | 408 ms | 312 ms: 1.31x faster | 321 ms: 1.27x faster | 297 ms: 1.38x faster | | async_tree_io | 1.14 sec | 868 ms: 1.31x faster | 889 ms: 1.28x faster | 824 ms: 1.38x faster | | async_tree_io_tg | 1.14 sec | 871 ms: 1.31x faster | 877 ms: 1.30x faster | 807 ms: 1.41x faster | | async_tree_memoization | 649 ms | 493 ms: 1.32x faster | 509 ms: 1.28x faster | 458 ms: 1.42x faster | | async_tree_memoization_tg | 605 ms | 453 ms: 1.34x faster | 462 ms: 1.31x faster | 425 ms: 1.42x faster | | async_tree_none_tg | 497 ms | 371 ms: 1.34x faster | 382 ms: 1.30x faster | 352 ms: 1.41x faster | | Geometric mean | (ref) | 1.26x faster | 1.27x faster | 1.38x faster | Benchmarks with tag 'math': | Benchmark | msvc.release.9db1a297d9 | clang.release.9db1a297d9 | msvc.pgo.9db1a297d9 | clang.pgo.9db1a297d9 | |----------------|-------------------------|--------------------------|----------------------|-----------------------| | float | 145 ms | 108 ms: 1.35x faster | 116 ms: 1.25x faster | 96.8 ms: 1.50x faster | | nbody | 203 ms | 155 ms: 1.31x faster | 171 ms: 1.19x faster | 128 ms: 1.58x faster | | pidigits | 245 ms | 250 ms: 1.02x slower | 250 ms: 1.02x slower | 240 ms: 1.02x faster | | Geometric mean | (ref) | 1.20x faster | 1.13x faster | 1.34x faster | Benchmarks with tag 'regex': | Benchmark | msvc.release.9db1a297d9 | clang.release.9db1a297d9 | msvc.pgo.9db1a297d9 | clang.pgo.9db1a297d9 | |----------------|-------------------------|--------------------------|-----------------------|-----------------------| | regex_compile | 237 ms | 180 ms: 1.31x faster | 180 ms: 1.31x faster | 157 ms: 1.51x faster | | regex_dna | 226 ms | 256 ms: 1.14x slower | 210 ms: 1.07x faster | 211 ms: 1.07x faster | | regex_effbot | 4.05 ms | not significant | 3.66 ms: 1.11x faster | 3.39 ms: 1.20x faster | | regex_v8 | 38.7 ms | 35.7 ms: 1.08x faster | 33.7 ms: 1.15x faster | 29.8 ms: 1.30x faster | | Geometric mean | (ref) | 1.06x faster | 1.16x faster | 1.26x faster | Benchmarks with tag 'serialize': | Benchmark | msvc.release.9db1a297d9 | clang.release.9db1a297d9 | msvc.pgo.9db1a297d9 | clang.pgo.9db1a297d9 | |----------------------|-------------------------|--------------------------|------------------------|------------------------| | json_dumps | 19.6 ms | 16.9 ms: 1.16x faster | 15.0 ms: 1.31x faster | 12.9 ms: 1.52x faster | | json_loads | 48.1 us | 46.7 us: 1.03x faster | 36.8 us: 1.31x faster | 32.7 us: 1.47x faster | | pickle | 21.5 us | 17.9 us: 1.20x faster | 19.1 us: 1.13x faster | 15.0 us: 1.44x faster | | pickle_dict | 46.0 us | 34.3 us: 1.34x faster | 43.2 us: 1.07x faster | 27.6 us: 1.67x faster | | pickle_list | 8.16 us | 6.19 us: 1.32x faster | 6.89 us: 1.18x faster | 5.05 us: 1.62x faster | | pickle_pure_python | 672 us | 455 us: 1.48x faster | 463 us: 1.45x faster | 378 us: 1.78x faster | | tomli_loads | 3.84 sec | 2.79 sec: 1.38x faster | 2.88 sec: 1.33x faster | 2.38 sec: 1.61x faster | | unpickle | 26.2 us | 24.0 us: 1.09x faster | 19.8 us: 1.32x faster | 17.9 us: 1.46x faster | | unpickle_list | 7.29 us | 6.03 us: 1.21x faster | 6.87 us: 1.06x faster | 5.38 us: 1.36x faster | | unpickle_pure_python | 505 us | 321 us: 1.57x faster | 336 us: 1.50x faster | 257 us: 1.96x faster | | xml_etree_parse | 232 ms | 228 ms: 1.02x faster | 200 ms: 1.16x faster | 210 ms: 1.10x faster | | xml_etree_iterparse | 185 ms | 160 ms: 1.16x faster | 154 ms: 1.21x faster | 145 ms: 1.27x faster | | xml_etree_generate | 181 ms | 148 ms: 1.22x faster | 135 ms: 1.35x faster | 119 ms: 1.53x faster | | xml_etree_process | 128 ms | 100 ms: 1.28x faster | 94.4 ms: 1.36x faster | 82.0 ms: 1.56x faster | | Geometric mean | (ref) | 1.24x faster | 1.26x faster | 1.51x faster | Benchmarks with tag 'startup': | Benchmark | msvc.release.9db1a297d9 | clang.release.9db1a297d9 | msvc.pgo.9db1a297d9 | clang.pgo.9db1a297d9 | |------------------------|-------------------------|--------------------------|-----------------------|-----------------------| | python_startup | 45.4 ms | not significant | 43.1 ms: 1.05x faster | 43.7 ms: 1.04x faster | | python_startup_no_site | 37.1 ms | not significant | 35.4 ms: 1.05x faster | 35.9 ms: 1.03x faster | | Geometric mean | (ref) | 1.00x faster | 1.05x faster | 1.04x faster | Benchmarks with tag 'template': | Benchmark | msvc.release.9db1a297d9 | clang.release.9db1a297d9 | msvc.pgo.9db1a297d9 | clang.pgo.9db1a297d9 | |-----------------|-------------------------|--------------------------|-----------------------|-----------------------| | django_template | 75.6 ms | 55.6 ms: 1.36x faster | 52.1 ms: 1.45x faster | 42.1 ms: 1.79x faster | | genshi_text | 44.5 ms | 31.4 ms: 1.42x faster | 32.5 ms: 1.37x faster | 26.3 ms: 1.69x faster | | genshi_xml | 102 ms | 74.0 ms: 1.37x faster | 74.6 ms: 1.36x faster | 63.1 ms: 1.61x faster | | mako | 23.3 ms | 17.7 ms: 1.31x faster | 16.7 ms: 1.39x faster | 14.4 ms: 1.61x faster | | Geometric mean | (ref) | 1.36x faster | 1.39x faster | 1.67x faster | All benchmarks: | Benchmark | msvc.release.9db1a297d9 | clang.release.9db1a297d9 | msvc.pgo.9db1a297d9 | clang.pgo.9db1a297d9 | |----------------------------------|-------------------------|--------------------------|------------------------|------------------------| | 2to3 | 586 ms | 491 ms: 1.19x faster | 462 ms: 1.27x faster | 426 ms: 1.38x faster | | async_generators | 696 ms | 565 ms: 1.23x faster | 577 ms: 1.21x faster | 514 ms: 1.35x faster | | async_tree_none | 511 ms | 383 ms: 1.33x faster | 394 ms: 1.30x faster | 357 ms: 1.43x faster | | async_tree_cpu_io_mixed | 933 ms | 805 ms: 1.16x faster | 749 ms: 1.25x faster | 697 ms: 1.34x faster | | async_tree_cpu_io_mixed_tg | 891 ms | 776 ms: 1.15x faster | 716 ms: 1.24x faster | 665 ms: 1.34x faster | | async_tree_eager | 209 ms | 153 ms: 1.37x faster | 160 ms: 1.31x faster | 133 ms: 1.57x faster | | async_tree_eager_cpu_io_mixed | 656 ms | 630 ms: 1.04x faster | 567 ms: 1.16x faster | 535 ms: 1.23x faster | | async_tree_eager_cpu_io_mixed_tg | 830 ms | 741 ms: 1.12x faster | 681 ms: 1.22x faster | 646 ms: 1.28x faster | | async_tree_eager_io | 1.12 sec | 870 ms: 1.29x faster | 874 ms: 1.28x faster | 817 ms: 1.37x faster | | async_tree_eager_io_tg | 1.12 sec | 890 ms: 1.26x faster | 898 ms: 1.25x faster | 840 ms: 1.33x faster | | async_tree_eager_memoization | 393 ms | 304 ms: 1.29x faster | 304 ms: 1.29x faster | 281 ms: 1.40x faster | | async_tree_eager_memoization_tg | 546 ms | 420 ms: 1.30x faster | 427 ms: 1.28x faster | 397 ms: 1.37x faster | | async_tree_eager_tg | 408 ms | 312 ms: 1.31x faster | 321 ms: 1.27x faster | 297 ms: 1.38x faster | | async_tree_io | 1.14 sec | 868 ms: 1.31x faster | 889 ms: 1.28x faster | 824 ms: 1.38x faster | | async_tree_io_tg | 1.14 sec | 871 ms: 1.31x faster | 877 ms: 1.30x faster | 807 ms: 1.41x faster | | async_tree_memoization | 649 ms | 493 ms: 1.32x faster | 509 ms: 1.28x faster | 458 ms: 1.42x faster | | async_tree_memoization_tg | 605 ms | 453 ms: 1.34x faster | 462 ms: 1.31x faster | 425 ms: 1.42x faster | | async_tree_none_tg | 497 ms | 371 ms: 1.34x faster | 382 ms: 1.30x faster | 352 ms: 1.41x faster | | asyncio_tcp | 1.64 sec | 1.55 sec: 1.06x faster | 1.48 sec: 1.11x faster | not significant | | asyncio_websockets | 732 ms | 578 ms: 1.27x faster | 758 ms: 1.04x slower | not significant | | chaos | 132 ms | 88.6 ms: 1.48x faster | 90.8 ms: 1.45x faster | 74.3 ms: 1.77x faster | | comprehensions | 34.7 us | 24.5 us: 1.42x faster | 25.2 us: 1.38x faster | 19.2 us: 1.80x faster | | bench_mp_pool | 213 ms | 196 ms: 1.09x faster | 177 ms: 1.20x faster | 190 ms: 1.12x faster | | bench_thread_pool | 1.95 ms | 1.74 ms: 1.12x faster | 1.68 ms: 1.16x faster | 1.63 ms: 1.19x faster | | coroutines | 45.3 ms | 33.9 ms: 1.34x faster | 36.1 ms: 1.25x faster | 26.9 ms: 1.68x faster | | coverage | 130 ms | 119 ms: 1.09x faster | 120 ms: 1.09x faster | 103 ms: 1.26x faster | | crypto_pyaes | 147 ms | 109 ms: 1.35x faster | 109 ms: 1.35x faster | 86.3 ms: 1.70x faster | | deepcopy | 516 us | 391 us: 1.32x faster | 388 us: 1.33x faster | 309 us: 1.67x faster | | deepcopy_reduce | 5.30 us | 4.19 us: 1.26x faster | 3.95 us: 1.34x faster | 3.23 us: 1.64x faster | | deepcopy_memo | 67.1 us | 41.6 us: 1.61x faster | 46.8 us: 1.44x faster | 34.8 us: 1.93x faster | | deltablue | 7.72 ms | 4.52 ms: 1.71x faster | 4.92 ms: 1.57x faster | 3.80 ms: 2.03x faster | | django_template | 75.6 ms | 55.6 ms: 1.36x faster | 52.1 ms: 1.45x faster | 42.1 ms: 1.79x faster | | docutils | 4.27 sec | 3.75 sec: 1.14x faster | 3.50 sec: 1.22x faster | 3.31 sec: 1.29x faster | | dulwich_log | 156 ms | 141 ms: 1.11x faster | 129 ms: 1.20x faster | 131 ms: 1.19x faster | | fannkuch | 770 ms | 592 ms: 1.30x faster | 637 ms: 1.21x faster | 516 ms: 1.49x faster | | float | 145 ms | 108 ms: 1.35x faster | 116 ms: 1.25x faster | 96.8 ms: 1.50x faster | | create_gc_cycles | 1.62 ms | 1.71 ms: 1.05x slower | not significant | 1.71 ms: 1.05x slower | | gc_traversal | 5.03 ms | not significant | 4.02 ms: 1.25x faster | 5.71 ms: 1.13x slower | | generators | 65.1 ms | 40.4 ms: 1.61x faster | 44.4 ms: 1.47x faster | 36.0 ms: 1.81x faster | | genshi_text | 44.5 ms | 31.4 ms: 1.42x faster | 32.5 ms: 1.37x faster | 26.3 ms: 1.69x faster | | genshi_xml | 102 ms | 74.0 ms: 1.37x faster | 74.6 ms: 1.36x faster | 63.1 ms: 1.61x faster | | go | 255 ms | 147 ms: 1.73x faster | 170 ms: 1.50x faster | 132 ms: 1.94x faster | | hexiom | 13.4 ms | 8.49 ms: 1.58x faster | 9.22 ms: 1.46x faster | 7.11 ms: 1.89x faster | | html5lib | 104 ms | 81.6 ms: 1.28x faster | 77.9 ms: 1.34x faster | 74.5 ms: 1.40x faster | | json_dumps | 19.6 ms | 16.9 ms: 1.16x faster | 15.0 ms: 1.31x faster | 12.9 ms: 1.52x faster | | json_loads | 48.1 us | 46.7 us: 1.03x faster | 36.8 us: 1.31x faster | 32.7 us: 1.47x faster | | logging_format | 21.2 us | 16.4 us: 1.29x faster | 14.7 us: 1.44x faster | 13.6 us: 1.56x faster | | logging_silent | 213 ns | 143 ns: 1.49x faster | 152 ns: 1.40x faster | 109 ns: 1.95x faster | | logging_simple | 19.4 us | 14.6 us: 1.33x faster | 13.5 us: 1.44x faster | 12.2 us: 1.60x faster | | mako | 23.3 ms | 17.7 ms: 1.31x faster | 16.7 ms: 1.39x faster | 14.4 ms: 1.61x faster | | mdp | 3.99 sec | 4.12 sec: 1.03x slower | 3.76 sec: 1.06x faster | 3.37 sec: 1.18x faster | | meteor_contest | 175 ms | 133 ms: 1.32x faster | 139 ms: 1.26x faster | 124 ms: 1.41x faster | | nbody | 203 ms | 155 ms: 1.31x faster | 171 ms: 1.19x faster | 128 ms: 1.58x faster | | nqueens | 179 ms | 129 ms: 1.38x faster | 131 ms: 1.37x faster | 103 ms: 1.73x faster | | pathlib | 278 ms | 266 ms: 1.04x faster | 256 ms: 1.09x faster | 262 ms: 1.06x faster | | pickle | 21.5 us | 17.9 us: 1.20x faster | 19.1 us: 1.13x faster | 15.0 us: 1.44x faster | | pickle_dict | 46.0 us | 34.3 us: 1.34x faster | 43.2 us: 1.07x faster | 27.6 us: 1.67x faster | | pickle_list | 8.16 us | 6.19 us: 1.32x faster | 6.89 us: 1.18x faster | 5.05 us: 1.62x faster | | pickle_pure_python | 672 us | 455 us: 1.48x faster | 463 us: 1.45x faster | 378 us: 1.78x faster | | pidigits | 245 ms | 250 ms: 1.02x slower | 250 ms: 1.02x slower | 240 ms: 1.02x faster | | pprint_safe_repr | 1.46 sec | 1.09 sec: 1.34x faster | 1.09 sec: 1.34x faster | 934 ms: 1.57x faster | | pprint_pformat | 3.00 sec | 2.22 sec: 1.35x faster | 2.23 sec: 1.35x faster | 1.91 sec: 1.57x faster | | pyflate | 875 ms | 626 ms: 1.40x faster | 668 ms: 1.31x faster | 537 ms: 1.63x faster | | python_startup | 45.4 ms | not significant | 43.1 ms: 1.05x faster | 43.7 ms: 1.04x faster | | python_startup_no_site | 37.1 ms | not significant | 35.4 ms: 1.05x faster | 35.9 ms: 1.03x faster | | raytrace | 587 ms | 385 ms: 1.52x faster | 414 ms: 1.42x faster | 321 ms: 1.83x faster | | regex_compile | 237 ms | 180 ms: 1.31x faster | 180 ms: 1.31x faster | 157 ms: 1.51x faster | | regex_dna | 226 ms | 256 ms: 1.14x slower | 210 ms: 1.07x faster | 211 ms: 1.07x faster | | regex_effbot | 4.05 ms | not significant | 3.66 ms: 1.11x faster | 3.39 ms: 1.20x faster | | regex_v8 | 38.7 ms | 35.7 ms: 1.08x faster | 33.7 ms: 1.15x faster | 29.8 ms: 1.30x faster | | richards | 102 ms | 65.3 ms: 1.56x faster | 64.7 ms: 1.58x faster | 49.7 ms: 2.05x faster | | richards_super | 116 ms | 74.3 ms: 1.57x faster | 74.7 ms: 1.56x faster | 56.2 ms: 2.07x faster | | scimark_fft | 664 ms | 485 ms: 1.37x faster | 493 ms: 1.35x faster | 358 ms: 1.85x faster | | scimark_lu | 227 ms | 159 ms: 1.43x faster | 164 ms: 1.39x faster | 132 ms: 1.72x faster | | scimark_monte_carlo | 138 ms | 91.6 ms: 1.51x faster | 101 ms: 1.37x faster | 74.6 ms: 1.85x faster | | scimark_sor | 256 ms | 176 ms: 1.46x faster | 195 ms: 1.31x faster | 151 ms: 1.69x faster | | scimark_sparse_mat_mult | 8.76 ms | 6.31 ms: 1.39x faster | 6.06 ms: 1.45x faster | 5.01 ms: 1.75x faster | | spectral_norm | 179 ms | 136 ms: 1.32x faster | 151 ms: 1.19x faster | 110 ms: 1.63x faster | | sqlglot_normalize | 204 ms | 156 ms: 1.31x faster | 151 ms: 1.35x faster | 131 ms: 1.55x faster | | sqlglot_optimize | 97.0 ms | 77.7 ms: 1.25x faster | 74.5 ms: 1.30x faster | 66.2 ms: 1.47x faster | | sqlglot_parse | 2.52 ms | 1.72 ms: 1.46x faster | 1.81 ms: 1.39x faster | 1.51 ms: 1.66x faster | | sqlglot_transpile | 3.02 ms | 2.15 ms: 1.41x faster | 2.21 ms: 1.37x faster | 1.85 ms: 1.63x faster | | sqlite_synth | 4.08 us | 3.81 us: 1.07x faster | 3.75 us: 1.09x faster | 3.44 us: 1.18x faster | | sympy_expand | 818 ms | 681 ms: 1.20x faster | 640 ms: 1.28x faster | 578 ms: 1.42x faster | | sympy_integrate | 33.5 ms | 28.2 ms: 1.19x faster | 27.1 ms: 1.24x faster | 24.2 ms: 1.38x faster | | sympy_sum | 258 ms | 222 ms: 1.16x faster | 213 ms: 1.21x faster | 199 ms: 1.29x faster | | sympy_str | 484 ms | 405 ms: 1.20x faster | 383 ms: 1.26x faster | 344 ms: 1.41x faster | | telco | 13.1 ms | 11.1 ms: 1.17x faster | 10.7 ms: 1.22x faster | 9.37 ms: 1.40x faster | | tomli_loads | 3.84 sec | 2.79 sec: 1.38x faster | 2.88 sec: 1.33x faster | 2.38 sec: 1.61x faster | | typing_runtime_protocols | 296 us | 239 us: 1.24x faster | 223 us: 1.32x faster | 193 us: 1.53x faster | | unpack_sequence | 152 ns | 58.2 ns: 2.61x faster | 84.8 ns: 1.79x faster | 59.3 ns: 2.56x faster | | unpickle | 26.2 us | 24.0 us: 1.09x faster | 19.8 us: 1.32x faster | 17.9 us: 1.46x faster | | unpickle_list | 7.29 us | 6.03 us: 1.21x faster | 6.87 us: 1.06x faster | 5.38 us: 1.36x faster | | unpickle_pure_python | 505 us | 321 us: 1.57x faster | 336 us: 1.50x faster | 257 us: 1.96x faster | | xml_etree_parse | 232 ms | 228 ms: 1.02x faster | 200 ms: 1.16x faster | 210 ms: 1.10x faster | | xml_etree_iterparse | 185 ms | 160 ms: 1.16x faster | 154 ms: 1.21x faster | 145 ms: 1.27x faster | | xml_etree_generate | 181 ms | 148 ms: 1.22x faster | 135 ms: 1.35x faster | 119 ms: 1.53x faster | | xml_etree_process | 128 ms | 100 ms: 1.28x faster | 94.4 ms: 1.36x faster | 82.0 ms: 1.56x faster | | Geometric mean | (ref) | 1.27x faster | 1.28x faster | 1.47x faster | Benchmark hidden because not significant (1): asyncio_tcp_ssl </p> </details> More benchmarks (including clang-cl 18.1.8, 20.1.0.rc2, `computed gotos` and `tailcall`) can be found in https://gist.github.com/chris-eibl/114a42f22563956fdb5cd0335b28c7ae. Raw data is here https://gist.github.com/chris-eibl/c73b02762a7c467e9a410a0aa19c7701.
d8a1cf469e40b538a84e583ac1d5d34418ed9a6a
3dd3675492a3fc3b7996613ef75a9044ee7449b0
python/cpython
python__cpython-130081
# Implement PEP 765 This issue serves as a tracker for implementing PEP-765. <!-- gh-linked-prs --> ### Linked PRs * gh-130081 * gh-130087 * gh-130930 * gh-131400 * gh-131471 * gh-131577 * gh-131745 <!-- /gh-linked-prs -->
56495f81fc7205b572173a03d418e0f9291f9eea
73d03005b028eb6e4d1a643f3ca7a1f5ff2040fc
python/cpython
python__cpython-130071
# `exec(<string>, closure=<non-None>)` failed assertion # Crash report ### What happened? Minimal repro: ```python print("Reproducing!") exec("", closure=object()) ``` Fails with ``` Reproducing! python: Python/ast.c:1047: _PyAST_Validate: Assertion `!PyErr_Occurred()' failed. Aborted (core dumped) ``` Note the error occurs not because the passed `closure=` is incorrect (it should be a tuple of cell objects), but because `closure=` is not allowed when string is the source. The reason for that to happen is a missing `goto error` jump: https://github.com/python/cpython/blob/2a0256f588e5c8ea3892521009ae3834c407cd69/Python/bltinmodule.c#L1175-L1178 causing the rest of the code to execute and reach `_PyAST_Validate`. In the PR, I included the missing test case. ### 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-dirty:f9a7d41bacb, Feb 13 2025, 04:52:15) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-130071 * gh-132627 <!-- /gh-linked-prs -->
954b2cf031fb84ff3386251d5c45281f47229003
d7df7815f555a4a5d6f4308072cbacd1286e8060
python/cpython
python__cpython-130061
# Pygettext: Support translator comments # Feature or enhancement ### Proposal: Most gettext extraction tools such as xgettext or pybabel allow one to extract additional comments written by the programmer which are meant to be read by the translator. These are prefixed with `#.` in the PO file. The comments typically look something like this: ```python # i18n: Translator comment _('foo') ``` This can be extracted with e.g. xgettext using `xgettext --add-comments=i18n`: ```po #. i18n: Translator comment msgid "foo" msgstr "" ``` Since this is a pretty widely used feature I propose we add this to pygettext as well. ### 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-130061 <!-- /gh-linked-prs -->
aa845af9bb39b3e2ed08bbb00a8e932a97be8fc0
6669905723238d45cde6c8a9b40579bfe73c76c1
python/cpython
python__cpython-130053
# Some error paths do not set Exceptions in _testexternalinspection # Bug report ### Bug description: Following @colesbury findings at https://github.com/python/cpython/issues/130035#issuecomment-2654033286, I did a manual inspection of `_testexternalinspection` and found a few more cases where Exception should be set. Will sent a PR soon. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130053 * gh-132594 * gh-132598 <!-- /gh-linked-prs -->
69426fcee7fcecbe34be66d2c5b58b6d0ffe2809
ca22147547413229a933e3d9cac21cbecf1183fe
python/cpython
python__cpython-130051
# Memory leaks at _testexternalinspection # Bug report ### Bug description: Following @colesbury findings at https://github.com/python/cpython/issues/130035#issuecomment-2654033286, I did a manual inspection of `_testexternalinspection` and found some memory leaks in `parse_coro_chain`, `parse_task` and `get_async_stack_trace`. Will send a PR soon. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130051 <!-- /gh-linked-prs -->
633853004c5b20827872a32e99cebef52ae0f531
1b27f36eb0ef146aa60b261a1cffcc6fd55c0e88
python/cpython
python__cpython-130040
# Tail calling interpreter for Windows # Feature or enhancement ### Proposal: Add new build flag for it. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-130040 <!-- /gh-linked-prs -->
a8ee1e16f545d721318afe8fe5330ddb4df7e3e3
4192ce17ba643e5b0bc9d2182a429002e4cc9dfe
python/cpython
python__cpython-130043
# Python 3.14.0a5 i686 Linux freethreading-debug build fails: gc_free_threading.c:1077: mark_heap_visitor: Assertion "gc_get_refs(op) >= 0" failed: refcount is too small # Bug report ### Bug description: I try to build freethreading-debug Python 3.14.0a5 for i686 Fedora Linux with a consistent failure: `/builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Python/gc_free_threading.c:1077: mark_heap_visitor: Assertion "gc_get_refs(op) >= 0" failed: refcount is too small`. This happens when freezing `importlib._bootstrap_external`, `zipimport`, `importlib._bootstrap`. The bigger log excerpt: ``` ./Programs/_freeze_module getpath /builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Modules/getpath.py Python/frozen_modules/getpath.h ./Programs/_freeze_module importlib._bootstrap_external /builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h /builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Python/gc_free_threading.c:1077: mark_heap_visitor: Assertion "gc_get_refs(op) >= 0" failed: refcount is too small Enable tracemalloc to get the memory block allocation traceback object address : 0xefc48188 object refcount : 1 object type : 0x56bef880 object type name: staticmethod object repr : <staticmethod(<built-in method maketrans of type object at 0x56be6ac0>)> Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed Python runtime state: core initialized Stack (most recent call first): <no Python frame> make: *** [Makefile:1772: Python/frozen_modules/importlib._bootstrap_external.h] Aborted (core dumped) make: *** Waiting for unfinished jobs.... ./Programs/_freeze_module zipimport /builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Lib/zipimport.py Python/frozen_modules/zipimport.h /builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Python/gc_free_threading.c:1077: mark_heap_visitor: Assertion "gc_get_refs(op) >= 0" failed: refcount is too small Enable tracemalloc to get the memory block allocation traceback object address : 0xefc48188 object refcount : 1 object type : 0x56be0880 object type name: staticmethod object repr : <staticmethod(<built-in method maketrans of type object at 0x56bd7ac0>)> Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed Python runtime state: core initialized Stack (most recent call first): <no Python frame> make: *** [Makefile:1775: Python/frozen_modules/zipimport.h] Aborted (core dumped) ./Programs/_freeze_module importlib._bootstrap /builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Lib/importlib/_bootstrap.py Python/frozen_modules/importlib._bootstrap.h /builddir/build/BUILD/python3.14-3.14.0_a5-build/Python-3.14.0a5/Python/gc_free_threading.c:1077: mark_heap_visitor: Assertion "gc_get_refs(op) >= 0" failed: refcount is too small Enable tracemalloc to get the memory block allocation traceback object address : 0xefc48188 object refcount : 1 object type : 0x56bb7880 object type name: staticmethod object repr : <staticmethod(<built-in method maketrans of type object at 0x56baeac0>)> Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed Python runtime state: core initialized Stack (most recent call first): <no Python frame> make: *** [Makefile:1769: Python/frozen_modules/importlib._bootstrap.h] Aborted (core dumped) ``` ### CPython versions tested on: 3.14 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130043 <!-- /gh-linked-prs -->
e09442089eb86d88d4b5a96e56f713cb31173ae9
791cdfe1416a591e240b8ffc6f10eb6f659c8277
python/cpython
python__cpython-130026
# iOS testbed clone breaks on some symlinks # Bug report ### Bug description: The iOS testbed project is able to use symlinks when referring to the XCframework (or simulator Framework slice of an XCframework). This saves significant disk space and startup time as the need to copy the full framework is eliminated. The `clone` subcommand of the testbed will duplicate this symlink; or, if a path to an XCframework (or simulator slice) is provided, that framework will be used instead. However: 1. If the testbed is cloned and *no* new framework is provided, and the symlink is specified as a relative link, the symlink will not work in the new location 2. If the existing framework symlink is invalid, any attempt to replace it fails because the existing link won't resolve. To replicate, generate an arm64 simulator build, then: 1. `python iOS/testbed clone testbed-1 --framework cross-build/arm64-apple-ios-simulator/iOS/Frameworks/arm64-iphonesimulator` (substitute path to simulator framework as appropriate) 2. `python testbed-1 clone tmp/testbed-2` 3. Inspect `tmp/testbed-2/Python.xcframework/ios-arm64_x86_64-simulator` - it will be an invalid symlink. 4. `python tmp/testbed-2 clone tmp/testbed-3` - this will fail because testbed-2 doesn't contain a simulator framework. 5. `python tmp/testbed-2 clone tmp/testbed-3 --framework cross-build/arm64-apple-ios-simulator/iOS/Frameworks/arm64-iphonesimulator` - this will fail with a FileNotFoundError looking for `.../cpython/tmp/cross-build/arm64-apple-ios-simulator/iOS/Frameworks/arm64-iphonesimulator`, which is what the testbed-2 framework symlink would resolve to (but doesn't exist). ### CPython versions tested on: 3.14 ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-130026 * gh-130073 <!-- /gh-linked-prs -->
625470a7d2c6aa79b5e60ffe17785ccc2547a090
2a0256f588e5c8ea3892521009ae3834c407cd69
python/cpython
python__cpython-130058
# Data race in `_PyType_AllocNoTrack` in free threaded build # Bug report Seen in https://github.com/python/cpython/actions/runs/13272883082/job/37056243083?pr=130015 ``` WARNING: ThreadSanitizer: data race (pid=17248) Write of size 8 at 0x7fbca00601d0 by thread T2652: #0 __tsan_memset <null> (python+0xdc7a8) (BuildId: cba02c45a3623f17982fb0d328c59833[13](https://github.com/python/cpython/actions/runs/13272883082/job/37056243083?pr=130015#step:14:14)92b589) #1 _PyType_AllocNoTrack /home/runner/work/cpython/cpython/Objects/typeobject.c:2251:5 (python+0x37dd92) (BuildId: cba02c45a3623f17982fb0d328c598331392b589) #2 PyType_GenericAlloc /home/runner/work/cpython/cpython/Objects/typeobject.c:2268:21 (python+0x37daf0) (BuildId: cba02c45a3623f17982fb0d328c598331392b589) #3 PyType_GenericNew /home/runner/work/cpython/cpython/Objects/typeobject.c:2282:12 (python+0x37e1a8) (BuildId: cba02c45a3623f17982fb0d328c598331392b589) #4 type_call /home/runner/work/cpython/cpython/Objects/typeobject.c:2183:11 (python+0x386be7) (BuildId: cba02c45a3623f17982fb0d328c598331392b589) #5 _PyObject_MakeTpCall /home/runner/work/cpython/cpython/Objects/call.c:242:18 (python+0x24ee43) (BuildId: cba02c45a3623f17982fb0d328c598331392b589) #6 _PyObject_VectorcallTstate /home/runner/work/cpython/cpython/./Include/internal/pycore_call.h:[16](https://github.com/python/cpython/actions/runs/13272883082/job/37056243083?pr=130015#step:14:17)5:16 (python+0x24e70b) (BuildId: cba02c45a3623f17982fb0d328c598331392b589) ... Previous atomic read of size 8 at 0x7fbca00601d0 by thread T2651: #0 _Py_atomic_load_uintptr_relaxed /home/runner/work/cpython/cpython/./Include/cpython/pyatomic_gcc.h:375:10 (python+0x382bea) (BuildId: cba02c45a3623f17982fb0d328c598331392b589) #1 _Py_IsOwnedByCurrentThread /home/runner/work/cpython/cpython/./Include/object.h:252:12 (python+0x382bea) #2 _Py_TryIncrefFast /home/runner/work/cpython/cpython/./Include/internal/pycore_object.h:560:9 (python+0x382bea) #3 _Py_TryIncref /home/runner/work/cpython/cpython/./Include/internal/pycore_object.h:764:12 (python+0x382bea) #4 _PyType_LookupRefAndVersion /home/runner/work/cpython/cpython/Objects/typeobject.c:5567:34 (python+0x382bea) #5 _PyType_LookupRef /home/runner/work/cpython/cpython/Objects/typeobject.c:5659:12 (python+0x37e522) (BuildId: cba02c[45](https://github.com/python/cpython/actions/runs/13272883082/job/37056243083?pr=130015#step:14:46)a3623f17982fb0d328c598331392b589) #6 _PyObject_GenericSetAttrWithDict /home/runner/work/cpython/cpython/Objects/object.c:1805:13 (python+0x3257d9) (BuildId: cba02c45a3623f17982fb0d328c598331392b589) ... ``` `_PyType_AllocNoTrack()` zeroes out the the allocation, including reference count fields. The memset is not atomic and so can race with `_Py_TryIncref` or similar function. I think we should `memset()` on the data after the `PyObject` header. The `ob_type` and reference count fields are immediately initialized after the `memset` anyways by `_PyObject_Init` or `_PyObject_InitVar`. https://github.com/python/cpython/blob/ed816f1a7088f5e85d9b27ed5828408dff007d18/Objects/typeobject.c#L2248-L2262 <!-- gh-linked-prs --> ### Linked PRs * gh-130058 <!-- /gh-linked-prs -->
0559339ccdc76a63dcbd14eb2d60a41f493a1ded
c357d690033e2f976ddb6e11b8199e3fb9f66118
python/cpython
python__cpython-130005
# PGO amd64 build broken on Windows: "Internal compiler error" # Bug report ### Bug description: The Windows release build is failing for 3.14.0a5 for MSVC 14.42.34433 on AMD64: ``` Merging D:\a\1\b\bin\amd64\python314!1.pgc D:\a\1\b\bin\amd64\python314!1.pgc: Used 25.9% (16346384 / 63139840) of total space reserved. 0.0% of the counts were dropped due to overflow. Reading PGD file 1: D:\a\1\b\bin\amd64\python314.pgd Creating library D:\a\1\b\bin\amd64\python314.lib and object D:\a\1\b\bin\amd64\python314.exp Generating code 0 of 0 ( 0.0%) original invalid call sites were matched. 0 new call sites were added. 261 of 16128 ( 1.62%) profiled functions will be compiled for speed, and the rest of the functions will be compiled for size 3>D:\a\1\s\Python\ceval.c(774): fatal error C1001: Internal compiler error. [D:\a\1\s\PCbuild\pythoncore.vcxproj] (compiler file 'D:\a\_work\1\s\src\vctools\Compiler\Utc\src\p2\main.cpp', line 253) To work around this problem, try simplifying or changing the program near the locations listed above. If possible please provide a repro here: https://developercommunity.visualstudio.com/ Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information link!InvokeCompilerPass()+0xdab22 link!InvokeCompilerPass()+0xdab22 link!InvokeCompilerPass()+0xda884 link!InvokeCompilerPass()+0xd76f7 link!InvokeCompilerPass()+0xd75fc link!InvokeCompilerPassW()+0xf25bd 3>Done Building Project "D:\a\1\s\PCbuild\pythoncore.vcxproj" (Build target(s)) -- FAILED. 1>Done Building Project "D:\a\1\s\PCbuild\pcbuild.proj" (Build target(s)) -- FAILED. Build FAILED. "D:\a\1\s\PCbuild\pcbuild.proj" (Build target) (1) -> "D:\a\1\s\PCbuild\pythoncore.vcxproj" (Build target) (3) -> (Link target) -> D:\a\1\s\Python\ceval.c(774): fatal error C1001: Internal compiler error. [D:\a\1\s\PCbuild\pythoncore.vcxproj] 0 Warning(s) 1 Error(s) ``` https://dev.azure.com/Python/cpython/_build/results?buildId=159104&view=logs&j=b9a7e24a-1d9b-5019-7703-8e6075dba299&t=339e554d-d1e3-55db-ce3b-12a33950552a ### CPython versions tested on: 3.14 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-130005 * gh-130009 <!-- /gh-linked-prs -->
247b50dec8af47ed8a80069117e07b7139f9d54f
374abded070b861cc389d509937344073193c36a
python/cpython
python__cpython-130001
# Some Windows API calls in winreg didn't release the GIL # Bug report ### Bug description: I'm not sure whether we should release the GIL in every Windows API call, but for specific Windows API calls, sometimes the GIL gets released, like [here](https://github.com/python/cpython/blob/1da412e574670cd8b48854112ba118c28ff2aba0/PC/winreg.c#L1788-L1791), and sometimes it doesn't, like [here](https://github.com/python/cpython/blob/1da412e574670cd8b48854112ba118c28ff2aba0/PC/winreg.c#L978-L979). ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-130001 * gh-134072 <!-- /gh-linked-prs -->
7a504b3d5da98874536834481539c19ba4a265af
6a2296329117463fd09abc73656f1d7b48076100
python/cpython
python__cpython-129996
# socket.create_server: dualstack_ipv6 and family # Documentation Calling `socket.create_server` with `dualstack_ipv6=True` expect `family=AF_INET`. For example: ``` socket.create_server(("", 12345), family=socket.AF_INET, dualstack_ipv6=True) ``` raise `ValueError`. There is nothing about it docs. We should add this constrain in docs. <!-- gh-linked-prs --> ### Linked PRs * gh-129996 * gh-131890 * gh-131891 <!-- /gh-linked-prs -->
044a1e13d5cfc91b0a8774e936877e91cbac3a16
a175d64e30b0ff9f011aea2da6d6e21ccfdcd893
python/cpython
python__cpython-129991
# `--without-tail-call-interp` actually enables the tail-call interpreter, instead of disabling! In `configure.ac`, if the user passes `--tail-call-interp` in the negative, we set `Py_TAIL_CALL_INTERP` to `0`: https://github.com/python/cpython/blob/1feaecc2bc42cb96f2d7bdc8d7083171bdcd0929/configure.ac#L7027-L7032 However, in `ceval_macros.h` and `bytecodes.c`, we check for `#ifdef Py_TAIL_CALL_INTERP` and `#if defined(Py_TAIL_CALL_INTERP)`, for instance: https://github.com/python/cpython/blob/1feaecc2bc42cb96f2d7bdc8d7083171bdcd0929/Python/ceval_macros.h#L76) Thus, defining the macro -- even with a value of `0` -- actually **enables** the feature! I think the consistent behavior (consistent with `USE_COMPUTED_GOTOS`) is probably to switch the preprocessor guards to `#if`, instead of `#ifdef`. <!-- gh-linked-prs --> ### Linked PRs * gh-129991 * gh-130269 <!-- /gh-linked-prs -->
359c7dde3bb074e029686913f531457eb121d1dd
c26bed1160978fe8b1844878b8123778e47870c6
python/cpython
python__cpython-132295
# computed-goto interpreter: Prevent the compiler from merging `DISPATCH` calls - [Work-in-progress test branch here](https://github.com/python/cpython/compare/main...nelhage:cpython:computed-goto-nomerge) As a reminder: when compiling the interpreter using computed gotos, we emit a separate copy of the "dispatch" jump (currently [`goto *opcode_targets[opcode]`](https://github.com/python/cpython/blob/1feaecc2bc42cb96f2d7bdc8d7083171bdcd0929/Python/ceval_macros.h#L98)) for each opcode implementation. The goal here -- as opposed to dispatching once at the top of the loop, and jumping to the top of the loop after each instruction -- is to expose more information to the hardware branch predictor (specifically, I believe, the branch **target** predictor, which tries to guess the destination of indirect branches). However, the C compiler doesn't know that! It does, however, see that we've given it a C function containing a few hundred instances of identical `DISPATCH` code … and may choose to merge them together, replacing one or more instances with a jump into the tail end of a different opcode, thus undoing our careful work! I suspect we can find a way to prevent the compiler from merging these branches, and thus restore similar branch-target-prediction behavior as in the tail-call interpreter. The branch above attempts to prevent this merging by adding an empty `__asm__ volatile` "optimization barrier" to each call site, in the hopes that the compiler treats this as opaque and refuses to merge them. I'm far from certain this is the best approach, but in my testing it seems to be a speedup -- I see 1.03x [on `pyperformance` on my machine](https://gist.github.com/nelhage/bd99284233d3e5a56f177388e078bd9a) (`goto-mine` is the linked branch with the optimization barrier). We can also observe the merging a bit more directly by counting the number of `DISPATCH` sites that remain after optimization, according to debug symbols: ## `main` ``` $ objdump -S --disassemble=_PyEval_EvalFrameDefault Python/ceval.o | grep -cF 'DISPATCH()' 47 ``` ## `nelhage/computed-goto-nomerge` ``` $ objdump -S --disassemble=_PyEval_EvalFrameDefault Python/ceval.o | grep -cF 'DISPATCH()' 306 ``` For comparison, `generated_cases.c.h` contains 227 instances on the same commit. <!-- gh-linked-prs --> ### Linked PRs * gh-132295 * gh-132530 <!-- /gh-linked-prs -->
1f5682f3a27516833f7c317707dd359280dba6e7
67ded6a4faae29edff8e4f7886978e71ce116e33
python/cpython
python__cpython-129985
# Immortal objects don't have the deferred bit set by default # Bug report ### Bug description: `_PyObject_HEAD_INIT` defines objects w/ an immortal reference count, but it doesn't set `_PyGC_BITS_DEFERRED`. This results in these objects (like small ints) not being cachable in the specializing interpreter loop for free threaded builds. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-129985 <!-- /gh-linked-prs -->
28f5e3de572e1f688b05126d395cf3aadd5ab8ad
0559339ccdc76a63dcbd14eb2d60a41f493a1ded
python/cpython
python__cpython-130015
# Data race in `compile_template` in `sre.c` # Bug report Concurrent accesses to `module_state->compile_template` in the free threaded build https://github.com/python/cpython/blob/1feaecc2bc42cb96f2d7bdc8d7083171bdcd0929/Modules/_sre/sre.c#L1169-L1177 <!-- gh-linked-prs --> ### Linked PRs * gh-130015 * gh-130038 <!-- /gh-linked-prs -->
3cf68cdd3e1809df4e426c61f6990de63747ec6f
469d2e416c453b19d7a75fe31ceec732445e9ef2
python/cpython
python__cpython-129981
# Include test suite name in TSAN log filename # Feature or enhancement If you run a lot of tests that log TSAN reports to a file, you are likely to get a bunch of different log files that look pretty similar. For example, something like: ``` tsan_log.3313980 tsan_log.3315274 ... ``` It can be difficult to figure out which test caused the data race, especially when the reported stack trace looks generic. For example, if the race happens in `_PyEval_EvalFrameDefault` or some other function not tied to a specific module, it's hard to know what caused the race. I'm proposing that we update `test/libregrtest/worker.py` to include the name of the test suite in the TSAN log filename. For example, the log files would instead look like: ``` tsan_log.test.test_asyncio.test_sendfile.3315095 tsan_log.test__interpchannels.3313611 ``` This makes it easier to find the test that triggered the race. <!-- gh-linked-prs --> ### Linked PRs * gh-129981 <!-- /gh-linked-prs -->
3b548adc765a83bedc316b19cb922a02c7a201f1
247b50dec8af47ed8a80069117e07b7139f9d54f
python/cpython
python__cpython-129978
# nogil set `clear` causes concurrent `__str__` to print as empty dict # Bug report ### Bug description: Hi, We're a research group focused on testing concurrent runtimes. Our work-in-progress prototype found that the current nogil build `__str__` can return `"{}"` (empty dict) instead of the expected `"set()"` when there is a concurrent `clear()` operation. The program below shows the wrong behavior: ```python import threading import sys def t0(b1,s,res): b1.wait() s.clear() def t1(b1,s,res): b1.wait() res.append(s.__str__()) def Test(): s = {17, 18, 'a', 'b', 'c', 'd', 'e'} threads=[] barrier = threading.Barrier(2) res = [] threads.append(threading.Thread(target= t0, args=(barrier, s,res))) threads.append(threading.Thread(target= t1, args=(barrier, s,res))) for i in range(0, len(threads)): threads[i].start() for i in range(0, len(threads)): threads[i].join() if res[0] == "{}": print("found bug: " + res[0]) print("test begin...") for i in range(0,50000): threads = [] if i % 1000 == 0: print(i) for i in range(0,100): threads.append(threading.Thread(target= Test)) for t in threads: t.start() for t in threads: t.join() print("test Done") ``` Sample output: ``` test begin... 0 found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} found bug: {} ``` This behavior can be observed quite readily. We tested it on a number of x86_64 and one ARM machine. @flypoodles and @overlorde are part of the team, adding them so they get notified about further discussion. ### CPython versions tested on: 3.14, CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-129978 * gh-130020 <!-- /gh-linked-prs -->
a7427f2db937adb4c787754deb4c337f1894fe86
1f233f56d6a5216b18e8c3f6b8c14d7e5d62c340
python/cpython
python__cpython-129969
# Add missing MIME types # Feature or enhancement ### Proposal: https://github.com/mikeckennedy/content-types identifies some common MIME types missing from the default `mimetypes` list. Running https://github.com/mikeckennedy/content-types/blob/main/samples/compare_to_builtin.py on Python 3.13 to identify some missing ones: ```console ❯ uv run --python 3.13 --with content-types https://raw.githubusercontent.com/mikeckennedy/content-types/refs/heads/main/samples/compare_to_builtin.py Compare types in mimetypes vs content-types. There are 5 types where mimetypes and content-types disagree mimetypes: .exe application/octet-stream, content-types: .exe application/x-msdownload mimetypes: .xml text/xml, content-types: .xml application/xml mimetypes: .wav audio/x-wav, content-types: .wav audio/wav mimetypes: .dll application/octet-stream, content-types: .dll application/x-msdownload mimetypes: .obj application/octet-stream, content-types: .obj model/obj There are 0 types in mimetypes that are not in content-types There are 31 types in content-types that are not in mimetypes in_ct_only .xlsx -> application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .gz -> application/gzip .ods -> application/vnd.oasis.opendocument.spreadsheet .docx -> application/vnd.openxmlformats-officedocument.wordprocessingml.document .gltf -> model/gltf+json .rar -> application/vnd.rar .php -> application/x-httpd-php .7z -> application/x-7z-compressed .ogv -> video/ogg .odg -> application/vnd.oasis.opendocument.graphics .weba -> audio/webm .rpm -> application/x-rpm .odp -> application/vnd.oasis.opendocument.presentation .deb -> application/x-debian-package .epub -> application/epub+zip .woff2 -> font/woff2 .apk -> application/vnd.android.package-archive .glb -> model/gltf-binary .map -> application/json .tgz -> application/gzip .ttf -> font/ttf .otf -> font/otf .wmv -> video/x-ms-wmv .odt -> application/vnd.oasis.opendocument.text .ogg -> audio/ogg .pptx -> application/vnd.openxmlformats-officedocument.presentationml.presentation .m4a -> audio/mp4 .m4v -> video/mp4 .flac -> audio/flac .woff -> font/woff .stl -> model/stl ``` With 3.14.0a4: ```console ❯ uv run --python 3.14 --with content-types https://raw.githubusercontent.com/mikeckennedy/content-types/refs/heads/main/samples/compare_to_builtin.py Compare types in mimetypes vs content-types. There are 5 types where mimetypes and content-types disagree mimetypes: .exe application/octet-stream, content-types: .exe application/x-msdownload mimetypes: .obj application/octet-stream, content-types: .obj model/obj mimetypes: .xml text/xml, content-types: .xml application/xml mimetypes: .wav audio/x-wav, content-types: .wav audio/wav mimetypes: .dll application/octet-stream, content-types: .dll application/x-msdownload There are 13 types in mimetypes that are not in content-types .wmf : image/wmf .mka : audio/matroska .fits: image/fits .g3 : image/g3fax .eot : application/vnd.ms-fontobject .emf : image/emf .jp2 : image/jp2 .jpm : image/jpm .jpx : image/jpx .t38 : image/t38 .mk3d: video/matroska-3d .mkv : video/matroska .tfx : image/tiff-fx There are 27 types in content-types that are not in mimetypes in_ct_only .m4v -> video/mp4 .wmv -> video/x-ms-wmv .odt -> application/vnd.oasis.opendocument.text .deb -> application/x-debian-package .odp -> application/vnd.oasis.opendocument.presentation .gz -> application/gzip .xlsx -> application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .map -> application/json .apk -> application/vnd.android.package-archive .gltf -> model/gltf+json .php -> application/x-httpd-php .glb -> model/gltf-binary .rpm -> application/x-rpm .epub -> application/epub+zip .odg -> application/vnd.oasis.opendocument.graphics .docx -> application/vnd.openxmlformats-officedocument.wordprocessingml.document .ods -> application/vnd.oasis.opendocument.spreadsheet .7z -> application/x-7z-compressed .stl -> model/stl .m4a -> audio/mp4 .ogv -> video/ogg .flac -> audio/flac .rar -> application/vnd.rar .tgz -> application/gzip .pptx -> application/vnd.openxmlformats-officedocument.presentationml.presentation .ogg -> audio/ogg .weba -> audio/webm ``` Let's add some of these, but check with [IANA](https://www.iana.org/assignments/media-types/media-types.xhtml) and relevant specs. For example, `.wav` is in [RFC 2361](https://datatracker.ietf.org/doc/html/rfc2361) as `audio/vnd.wave` not `audio/wav`. We currently have it as `audio/x-wav`. ### 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-129969 * gh-132845 <!-- /gh-linked-prs -->
1cf9b6d9b8fbb5ebc3e9b42a3682684a983c78bc
d0a1e5c222f9f43b492b28806e2a185a50d64500
python/cpython
python__cpython-130882
# JIT build crashes on Windows on Arm # Crash report ### What happened? The JIT on Windows on Arm (tested on Windows 11 Pro) is broken. It builds successfully but then the first test fails straightaway crashing the binary. Also if I run the REPL and start typing commands, it stays alive for a few seconds and then dies. When Python is built without the JIT, the test suite passes. ``` PS C:\Users\ent-user\cpython> .\PCbuild\build.bat -p ARM64 --experimental-jit .... .... Generating code Finished generating code python.vcxproj -> C:\Users\ent-user\cpython\PCbuild\arm64\python.exe Wrote C:\Users\ent-user\cpython\PCbuild\arm64\LICENSE.txt Generating code Finished generating code pythonw.vcxproj -> C:\Users\ent-user\cpython\PCbuild\arm64\pythonw.exeBuild succeeded.C:\Users\ent-user\cpython\Python\optimizer_symbols.c(487,20): warning C4244: 'return': conversion from 'Py_ssize_t' to 'int', possible loss of data [C:\Users\ent-user\cpython\PCbuild\pythoncore.vcxproj] 1 Warning(s) 0 Error(s)Time Elapsed 00:02:07.70 PS C:\Users\ent-user\cpython> .\python.bat -m test Running Release|ARM64 interpreter... == CPython 3.14.0a4+ (heads/main:d7672e5d5a, Feb 10 2025, 15:21:49) [MSC v.1940 64 bit (ARM64)] == Windows-11-10.0.26100-SP0 little-endian == Python build: release with_assert == cwd: C:\Users\ent-user\cpython\build\test_python_worker_5516æ == CPU count: 8 == encodings: locale=cp1252 FS=utf-8 == resources: all test resources are disabled, use -u option to unskip tests Using random seed: 1919085789 0:00:00 Run 484 tests sequentially in a single process 0:00:00 [ 1/484] test.test_asyncio.test_base_events Windows fatal exception: access violation Thread 0x0000093c (most recent call first): File "C:\Users\ent-user\cpython\Lib\linecache.py", line 75 in checkcache File "C:\Users\ent-user\cpython\Lib\traceback.py", line 487 in _extract_from_extended_frame_gen File "C:\Users\ent-user\cpython\Lib\traceback.py", line 445 in extract File "C:\Users\ent-user\cpython\Lib\asyncio\format_helpers.py", line 80 in extract_stack File "C:\Users\ent-user\cpython\Lib\asyncio\events.py", line 55 in __init__ File "C:\Users\ent-user\cpython\Lib\asyncio\events.py", line 123 in __init__ File "__init__", line ??? in __init__ File "C:\Users\ent-user\cpython\Lib\asyncio\base_events.py", line 875 in call_soon_threadsafe File "C:\Users\ent-user\cpython\Lib\asyncio\base_events.py", line 2062 in set_debug File "C:\Users\ent-user\cpython\Lib\test\test_asyncio\test_base_events.py", line 310 in check_thread File "C:\Users\ent-user\cpython\Lib\test\test_asyncio\test_base_events.py", line 340 in check_in_thread File "C:\Users\ent-user\cpython\Lib\threading.py", line 996 in run File "C:\Users\ent-user\cpython\Lib\threading.py", line 1054 in _bootstrap_inner File "C:\Users\ent-user\cpython\Lib\threading.py", line 1016 in _bootstrap Thread 0x00003824 (most recent call first): File "C:\Users\ent-user\cpython\Lib\test\libregrtest\win_utils.py", line 47 in _update_load Current thread 0x00001db8 (most recent call first): File "C:\Users\ent-user\cpython\Lib\asyncio\base_events.py", line 1965 in _run_once File "C:\Users\ent-user\cpython\Lib\asyncio\base_events.py", line 677 in run_forever File "C:\Users\ent-user\cpython\Lib\asyncio\base_events.py", line 706 in run_until_complete File "C:\Users\ent-user\cpython\Lib\test\test_asyncio\test_base_events.py", line 353 in test_thread File "C:\Users\ent-user\cpython\Lib\test\test_asyncio\test_base_events.py", line 360 in test_check_thread File "C:\Users\ent-user\cpython\Lib\unittest\case.py", line 606 in _callTestMethod File "C:\Users\ent-user\cpython\Lib\unittest\case.py", line 660 in run File "C:\Users\ent-user\cpython\Lib\unittest\case.py", line 716 in __call__ File "C:\Users\ent-user\cpython\Lib\unittest\suite.py", line 122 in run File "C:\Users\ent-user\cpython\Lib\unittest\suite.py", line 84 in __call__ File "C:\Users\ent-user\cpython\Lib\unittest\suite.py", line 122 in run File "C:\Users\ent-user\cpython\Lib\unittest\suite.py", line 84 in __call__ File "C:\Users\ent-user\cpython\Lib\test\libregrtest\testresult.py", line 148 in run File "C:\Users\ent-user\cpython\Lib\test\libregrtest\single.py", line 84 in _run_suite File "C:\Users\ent-user\cpython\Lib\test\libregrtest\single.py", line 42 in run_unittest File "C:\Users\ent-user\cpython\Lib\test\libregrtest\single.py", line 162 in test_func File "C:\Users\ent-user\cpython\Lib\test\libregrtest\single.py", line 118 in regrtest_runner File "C:\Users\ent-user\cpython\Lib\test\libregrtest\single.py", line 165 in _load_run_test File "C:\Users\ent-user\cpython\Lib\test\libregrtest\single.py", line 210 in _runtest_env_changed_exc File "C:\Users\ent-user\cpython\Lib\test\libregrtest\single.py", line 319 in _runtest File "C:\Users\ent-user\cpython\Lib\test\libregrtest\single.py", line 348 in run_single_test File "C:\Users\ent-user\cpython\Lib\test\libregrtest\main.py", line 378 in run_test File "C:\Users\ent-user\cpython\Lib\test\libregrtest\main.py", line 412 in run_tests_sequentially File "C:\Users\ent-user\cpython\Lib\test\libregrtest\main.py", line 559 in _run_tests File "C:\Users\ent-user\cpython\Lib\test\libregrtest\main.py", line 594 in run_tests File "C:\Users\ent-user\cpython\Lib\test\libregrtest\main.py", line 766 in main File "C:\Users\ent-user\cpython\Lib\test\libregrtest\main.py", line 774 in main File "C:\Users\ent-user\cpython\Lib\test\__main__.py", line 2 in <module> File "<frozen runpy>", line 88 in _run_code File "<frozen runpy>", line 198 in _run_module_as_main PS C:\Users\ent-user\cpython> ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows ### Output from running 'python -VV' on the command line: .\python.bat -VV Running Release|ARM64 interpreter... Python 3.14.0a4+ (heads/main:d7672e5d5a, Feb 10 2025, 15:21:49) [MSC v.1940 64 bit (ARM64)] <!-- gh-linked-prs --> ### Linked PRs * gh-130882 <!-- /gh-linked-prs -->
02de9cb9a8fa5b0ae3947231b8c0677834aaee45
5d8db36bbbab166c4c221ee6e283f090475c5def
python/cpython
python__cpython-130063
# Vague behavior when single quoted f-string format_spec contains line break # Bug report ### Bug description: ```python >>> value = 123 >>> f"{value:.{'2'}f}" # '123.00' >>> f"{value:. {'2f'}}" # '123.00' # but, shouldn't this one below also be valid? >>> f"{value:. ... {'2'}f}" # invalid >>> f"{value: ... {'.2f'}}" # '123.00' ``` I am checking the code of CPython's lexer and am confused why the lexer resets to normal mode when it encounters line break in format spec https://github.com/python/cpython/blob/d7672e5d5a7b9580a72dbe75d3a9e8840bcc604c/Parser/lexer/lexer.c#L1338-L1348 Go back to the original PR: https://github.com/python/cpython/pull/110271 Seems this case is not covered by the test cases The case above could be recognized by tokenizer, so maybe pegen should be modified. However, since it goes back to normal mode, some corner cases cannot be handled by tokenizer: ```python >>> value = 123 >>> f"{value:#{'x'}}" # '0x7b' >>> f"{value: ... #{'x'}}" # breaks the tokenizer ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-130063 * gh-132692 * gh-135570 * gh-135982 <!-- /gh-linked-prs -->
2f8b08da475152adea59b6bf98e2d0cb73dd8a59
e01e5829020e517eb68a47da4dd65926a9d144de
python/cpython
python__cpython-129949
# Add `set()` to `multiprocessing.managers.SyncManager` # Feature or enhancement ### Proposal: The SyncManager provides support for various data structures such as dict, list, and queue, but oddly, it does not support set. This inconsistency feels little bit weird. Unless there is a specific reason, I propose adding support for set as well. ```python from multiprocessing import managers managers.SyncManager.set() set.add('foo') # ... something else ... ``` ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-129949 <!-- /gh-linked-prs -->
9f81f828c797f842d1df0a5cbda898bc0df8075a
a65366ed879a3d9f27cbcc811ed2e05ad1a2af06
python/cpython
python__cpython-129940
# Add darkmode support for difflib's comparison pages # Feature or enhancement ### Proposal: Previously, a similar change was made in https://github.com/python/cpython/pull/123475, which was considered a new feature. ![Image](https://github.com/user-attachments/assets/5ad80601-15ea-4aec-8abe-2f494dd570e3) ### 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-129940 <!-- /gh-linked-prs -->
12bd15f7b378879ed7971d14a4388cd9a38a14dc
3b366a4a4b0cea483824adbc2fa5a19d82d3dc6a
python/cpython
python__cpython-129929
# Refactor sqlite3 error handler In most error cases, we can use the error indicator from the SQLite database pointer when we raise exceptions. However, for some SQLite C APIs, we have to use the result code directly. This is the case for some of the blob APIs, where the error indicator is not stored on the database pointer. Currently, our "set error" handler only handles the case where the error indicator is set on the database pointer. We also need an `Modules/_sqlite` private API for raising exception from the SQLite C API result codes. See also https://github.com/python/cpython/pull/128507#discussion_r1903334073 <!-- gh-linked-prs --> ### Linked PRs * gh-129929 * gh-129941 <!-- /gh-linked-prs -->
3b366a4a4b0cea483824adbc2fa5a19d82d3dc6a
3a2e7aacf6f414bbbedaf072e7cb1b48e3d402fa
python/cpython
python__cpython-131025
# Update installers to use SQLite 3.49 ### Proposal: We'e been skipping some SQLite versions lately; currently we're shipping the macOS and Windows installers with SQLite 3.45.3 (released 300 days ago, 2024-04-15). SQLite 3.49.0 recently came out, so we should probably hold off upgrading for a couple of weeks to see if patch releases appear. See also #129870. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-131025 * gh-131957 * gh-131958 <!-- /gh-linked-prs -->
45a3ab5a81769eadd94da3e26eb9bb2f3ae80fb1
2e96f5ae4d1700d77a53180b4866c5b9f002e62d
python/cpython
python__cpython-130044
# The tp_dictoffset and Py_TPFLAGS_MANAGED_WEAKREF flag From the `tp_dictoffset` slot documentation: >"It is an error to set both the **`Py_TPFLAGS_MANAGED_WEAKREF`** bit and `tp_dictoffset`." I think the `Py_TPFLAGS_MANAGED_WEAKREF` flag is being used **incorrectly** in this context. Do you mean the `Py_TPFLAGS_MANAGED_DICT` flag? https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_dictoffset <!-- gh-linked-prs --> ### Linked PRs * gh-130044 * gh-130059 * gh-130060 <!-- /gh-linked-prs -->
791cdfe1416a591e240b8ffc6f10eb6f659c8277
633853004c5b20827872a32e99cebef52ae0f531
python/cpython
python__cpython-129914
# pygettext: help output for keywords prints the whole keyword dictionary # Bug report ### Bug description: The `--keyword` entry when printing the help via `./python Tools/i18n/pygettext.py --help` shows the whole keyword dictionary: ``` -k word --keyword=word Keywords to look for in addition to the default set, which are: {'_': {0: 'msgid'}, 'gettext': {0: 'msgid'}, 'ngettext': {0: 'msgid', 1: 'msgid_plural'}, 'pgettext': {0: 'msgctxt', 1: 'msgid'}, 'npgettext': {0: 'ms gctxt', 1: 'msgid', 2: 'msgid_plural'}, 'dgettext': {1: 'msgid'}, 'dngettext': {1: 'msgid', 2: 'msgid_plural'}, 'dpgettext': {1: 'msgctxt', 2: 'msgid'}, 'dnpg ettext': {1: 'msgctxt', 2: 'msgid', 3: 'msgid_plural'}} You can have multiple -k flags on the command line. ``` This is because the format of `DEFAULTKEYWORDS` recently changed from a list to a dictionary. We should just list the function names as we did before. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-129914 <!-- /gh-linked-prs -->
9d1e668e6f40967dda5cbb1ce298bf0dff2d807c
3bd3e09588bfde7edba78c55794a0e28e2d21ea5
python/cpython
python__cpython-129901
# Exit code in case of an error is always 1 since Python 3.13 # Bug report ### Bug description: We noticed a failure of our Vim test suite on the Github Windows runners, when it was updated from python3.12 to python3.13. Vim basically does run in a terminal `exit(123)` and expects the return code to be 123, however, since python3.13 the return code seems to be 1. Note this works find on the linux jobs, just on Windows this does not work correctly. Also note, python3 -c 'exit(123)' seems to work correctly, only when using an interactive session it doesn't seem to work right. related: - vim/vim#16546 (see in particular this [comment](https://github.com/vim/vim/issues/16546#issuecomment-2646133046)) - actions/runner-images#11512 ```python exit(123) ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-129901 * gh-131734 <!-- /gh-linked-prs -->
90b82f2b61219c8f94e2deddc989a4c4fe9ea7c7
8ada7a9e1435302ec2cb73375122072d0e1cdd6f