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-125272
# Fix thread-safety of interpreter cached object `str_replace_inf` (free threading) # Bug report We have a number of per-interpreter cached objects. Some of these are lazily initialized in a way that is not thread-safe in the free threading build. (See https://github.com/python/cpython/issues/125221, for example). We should go through the remaining ones and make sure they are thread-safe. **EDIT**: The only remaining field is `str_replace_inf`. Accesses to `type_slots_pname` and `type_slots_ptrs` are protected by a lock and the TypeVar fields are initialized once early on with other types. https://github.com/python/cpython/blob/01fc3b34cc6994bc83b6540da3a8573e79dfbb56/Include/internal/pycore_global_objects.h#L63-L85 <!-- gh-linked-prs --> ### Linked PRs * gh-125272 * gh-125280 <!-- /gh-linked-prs -->
427dcf24de4e06d239745d74d08c4b2e541dca5a
bb594e801b6a84823badbb85b88f0fc8b221d7bf
python/cpython
python__cpython-125261
# gzip.compress output is non-deterministic # Bug report ### Bug description: ```python import gzip gzip.compress(b'') ``` output varies by default, which breaks reproducible builds in cases such as https://github.com/getmoto/moto/blob/fc60bd1c5f6e6184e30a6db8b65059a2855cd28e/setup.py#L28 GNU gzip (since 1.10) defaults to a zero timestamp for compressing stdin. And after year 2106, no mtime could be stored anyway. ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-125261 <!-- /gh-linked-prs -->
dcd58c50844dae0d83517e88518a677914ea594b
9944ad388c457325456152257b977410c4ec3593
python/cpython
python__cpython-125647
# `TypeError` when raising an exception inside the `__init__` method of an enum class # Bug report ### Bug description: With https://github.com/python/cpython/pull/111815, any exception raised inside the `__init__` method of an enum class [^1] is expected to be: 1. instantiable (not the case with Pydantic `ValidationError`s, see https://github.com/pydantic/pydantic/issues/10593) 2. instantiable and expected to take a single argument. https://github.com/python/cpython/blob/120b891e4dff692aef0c2b16d887459b88a76a1b/Lib/enum.py#L556-L566 Meaning the following raises a `TypeError` instead of the expected `MyValueError`: ```python class MyValueError(ValueError): def __init__(self, t: str, v: int) -> None: self.t = t self.v = v class ValidatedEnum(Enum): def __init__(self, value): raise MyValueError("", 1) class MyValidatedEnum(ValidatedEnum): FOO = "foo" # TypeError: MyValueError.__init__() missing 1 required positional argument: 'v' ``` [^1]: An example is documented as an example [here](https://docs.python.org/3/howto/enum.html#duplicatefreeenum). ### CPython versions tested on: 3.12 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-125647 * gh-125858 * gh-125953 <!-- /gh-linked-prs -->
34653bba644aa5481613f398153757d7357e39ea
aaed91cabcedc16c089c4b1c9abb1114659a83d3
python/cpython
python__cpython-125273
# Argparse logs incorrect ambiguous option # Bug report ### Bug description: Given this example script ```python import argparse class CsvListAction(argparse.Action): """ argparse Action to convert "a,b,c" into ["a", "b", "c"] """ def __call__(self, parser, namespace, values, option_string=None): # Conversion to dict removes duplicates while preserving order items = list(dict.fromkeys(values.split(",")).keys()) setattr(namespace, self.dest, items) parser = argparse.ArgumentParser(description="Testing") parser.add_argument("directory", type=str, help="path to find files") parser.add_argument( "--output", type=str, help="name of output file to produce", ) name_args_group = parser.add_mutually_exclusive_group() name_args_group.add_argument( "--name-exclude", action=CsvListAction, help="Comma-separated set of name ID(s) to exclude", ) name_args_group.add_argument( "--name-include", action=CsvListAction, help="Comma-separated set of name ID(s) to include", ) parser.add_argument( "--path-exclude", action=CsvListAction, default=[], help="Comma-separated set of UNIX glob patterns to exclude", ) parser.add_argument( "--path-include", action=CsvListAction, default=[], help="Comma-separated set of UNIX glob patterns to include", ) parser.parse_args() ``` **Notice the cli args are `name-exclude` and `name-include`** Run the following command, which incorrectly puts the arg as `--name` `python argparse_mini.py /some/path --output here.txt --name something --path-exclude *request.py` If you run it with Python 3.12.2 or below, the resulting log statement is what we expect `argparse_mini.py: error: ambiguous option: --name could match --name-exclude, --name-include` However, tested with 3.12.7 and the log statement instead is `argparse_mini.py: error: ambiguous option: *request.py could match --name-exclude, --name-include` which is clearly incorrect, as `*request.py` was the argument to a different CLI option ### CPython versions tested on: 3.11, 3.12 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-125273 * gh-125359 * gh-125360 <!-- /gh-linked-prs -->
63cf4e914f879ee28a75c02e867baa7c6047ea2b
07c2d15977738165e9dc4248e7edda7c75ecc14b
python/cpython
python__cpython-125415
# Race condition when importing `collections.abc` # Bug report ### Bug description: Discovered alongside #125243 with similar steps to reproduce. I don't have a simpler way to trigger this than "run the PyO3 tests in a loop" because I think it requires many threads accessing the python runtime simulatenously. To trigger it, have a rust toolchain and Python installed, clone the PyO3 repo and execute the following command: ``` while RUST_BACKTRACE=1 UNSAFE_PYO3_BUILD_FREE_THREADED=1 cargo test --lib --features=full -- --test-threads=100; do :; done ``` You may also hit some other test failures related to ZoneInfo, see the other issue I opened about that. You will eventually see a test failure with the following text: ``` ---- exceptions::socket::tests::gaierror stdout ---- thread 'exceptions::socket::tests::gaierror' panicked at src/impl_/exceptions.rs:26:17: failed to import exception socket.gaierror: ImportError: cannot import name 'Mapping' from 'collections.abc' (/Users/goldbaum/.pyenv/versions/3.13.0t/lib/python3.13t/collections/abc.py) ``` I slightly modified PyO3 to get a traceback as well (hidden because it's a distractingly long diff): <details> ``` diff --git a/src/impl_/exceptions.rs b/src/impl_/exceptions.rs index 15b6f53b..de63ad59 100644 --- a/src/impl_/exceptions.rs +++ b/src/impl_/exceptions.rs @@ -1,4 +1,8 @@ -use crate::{sync::GILOnceCell, types::PyType, Bound, Py, Python}; +use crate::{ + sync::GILOnceCell, + types::{PyTracebackMethods, PyType}, + Bound, Py, Python, +}; pub struct ImportedExceptionTypeObject { imported_value: GILOnceCell<Py<PyType>>, @@ -20,8 +24,11 @@ impl ImportedExceptionTypeObject { .import(py, self.module, self.name) .unwrap_or_else(|e| { panic!( - "failed to import exception {}.{}: {}", - self.module, self.name, e + "failed to import exception {}.{}: {}\n{}", + self.module, + self.name, + e, + e.traceback(py).unwrap().format().unwrap(), ) }) } ``` </details> And the traceback is: ``` Traceback (most recent call last): File "/Users/goldbaum/.pyenv/versions/3.13.0t/lib/python3.13t/socket.py", line 55, in <module> import os, sys, io, selectors File "/Users/goldbaum/.pyenv/versions/3.13.0t/lib/python3.13t/selectors.py", line 10, in <module> from collections.abc import Mapping ``` So somehow during setup of the `socket` module, `Mapping` isn't available yet, but only if many threads are simultaneously touching the Python runtime. (ping @davidhewitt, we probably want to disable the socket error tests on the free-threaded build as well) ### CPython versions tested on: 3.13 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-125415 * gh-125944 <!-- /gh-linked-prs -->
fed501d7247053ce46a2ba512bf0e4bb4f483be6
332356b880576a1a00b5dc34f03d7d3995dd4512
python/cpython
python__cpython-125281
# ZoneInfo comparison fails on free-threaded build # Bug report ### Bug description: (originally noticed by @davidhewitt in https://github.com/python/cpython/issues/116738#issuecomment-2404360445) Very infrequently, PyO3 tests for timezone conversions will fail with errors like: ``` ---- conversions::chrono_tz::tests::test_into_pyobject stdout ---- thread 'conversions::chrono_tz::tests::test_into_pyobject' panicked at src/conversions/chrono_tz.rs:120:17: zoneinfo.ZoneInfo(key='UTC') != zoneinfo.ZoneInfo(key='UTC') ``` Unfortunately, I don't have an easier way to trigger this besides "run the PyO3 tests over and over until you see a failure", since I think triggering it requires many threads simultaneously using the C API which happens automatically with cargo for the PyO3 tests. The test code is here: https://github.com/PyO3/pyo3/blob/eacebb8db101d05ae4ccf0396e314b098455ecd3/src/conversions/chrono_tz.rs#L116-L134 I believe that rust is more or less doing the equivalent of this C code: ``` #include <Python.h> int main() { if (Py_IsInitialized() == 0) { Py_InitializeEx(0); PyObject *mod = PyImport_ImportModule("zoneinfo"); if (mod == NULL) { PyErr_PrintEx(0); return -1; } PyObject *zoneinfo = PyObject_GetAttrString(mod, "ZoneInfo"); if (zoneinfo == NULL) { PyErr_PrintEx(0); return -1; } PyObject *arg = PyUnicode_FromString("Europe/Paris"); PyObject *obj1 = PyObject_CallOneArg(zoneinfo, arg); PyObject *obj2 = PyObject_CallOneArg(zoneinfo, arg); PyObject *result = PyObject_RichCompare(obj1, obj2, Py_EQ); PyObject_Print(result, stderr, Py_PRINT_RAW); } return 0; } ``` This doesn't fail, which makes me suspect triggering it requires touching the C API in other threads. ### CPython versions tested on: 3.13 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-125281 * gh-125414 <!-- /gh-linked-prs -->
f1d33dbddd3496b062e1fbe024fb6d7b023a35f5
cb8e5995d89d9b90e83cf43310ec50e177484e70
python/cpython
python__cpython-125250
# win 10 Python-3.13.0 tkinter fails in venv # Bug report ### Bug description: Installed python 3.13.0 in windows 10 at c:\python313 created venv at c:\users\rptla\tmp\py313 Tkinter based app failed to start in the venv. After testing tkinter I see these results ie error in venv starting Tk() wotks in installed. In the venv ```bash (py313) C:\Users\rptla\tmp\py313>python Python 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter >>> root = tkinter.Tk() Traceback (most recent call last): File "<python-input-1>", line 1, in <module> root = tkinter.Tk() File "C:\python313\Lib\tkinter\__init__.py", line 2459, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _tkinter.TclError: Can't find a usable init.tcl in the following directories: C:/python313/lib/tcl8.6 C:/lib/tcl8.6 C:/lib/tcl8.6 C:/library C:/library C:/tcl8.6.14/library C:/tcl8.6.14/library This probably means that Tcl wasn't installed properly. >>> ``` in installed python ```bash C:\Python313\Lib\tkinter>\python313\python Python 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter >>> root=tkinter.Tk() >>> ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-125250 * gh-125312 <!-- /gh-linked-prs -->
b3aa1b5fe260382788a2df416599325ad680a5ee
18c74497681e0107d7cde53e63ea42feb38f2176
python/cpython
python__cpython-125266
# Make PyInitConfig_Free(NULL) a no-op # Feature or enhancement I think that it would simplify the code if make `PyInitConfig_Free(NULL)` a no-op. Currently it requires the argument to be non-NULL. This would simplify the code: ```c PyInitConfig *config = NULL; // some code if (error_occurred) { goto Error; } config = PyInitConfig_Create(); if (config == NULL) { goto Error; } // some other code if (error_occurred) { goto Error; } // more code Error: // release resources if (config == NULL) { PyInitConfig_Free(config); } // release resources ``` Most Python resources are represented as Python objects, so `Py_XDECREF(NULL)` works for them. `PyMem_Free(NULL)` and `PyRawMem_Free(NULL)` work for raw memory blocks. `PyInitConfig_Free()` is one of few (or only one) API that cannot be used in such idiom. <!-- gh-linked-prs --> ### Linked PRs * gh-125266 <!-- /gh-linked-prs -->
546dddca43a2a69dbe33d230e9e540636b403270
92af191a6a5f266b71373f5374ca0c9c522d62d9
python/cpython
python__cpython-125226
# Misaligned columns in help('topics') due to the length of "ASSIGNMENTEXPRESSIONS" # Documentation ### Description The [`pydoc.Helper.list`](https://github.com/python/cpython/blob/main/Lib/pydoc.py#L2085) function currently uses default values of 80 characters per line and 4 columns. This provides an implicit maximum length of 19 characters per item to ensure columns are aligned properly (the item length is not verified within the function). Historically, the longest values were `_testimportmultiple` from `help('module')` and `AUGMENTEDASSIGNMENT` from `help('topics')`, both with a length of 19 characters. The recent addition of `"ASSIGNMENTEXPRESSIONS"` (21 characters) in [PR 124641](https://github.com/python/cpython/pull/124641) causes misaligned columns with these default values. As seen in Python 3.13.0: ``` >>> help('topics') Here is a list of available topics. Enter any topic name to get more help. ASSERTION DEBUGGING LITERALS SEQUENCES ASSIGNMENT DELETION LOOPING SHIFTING ASSIGNMENTEXPRESSIONS DICTIONARIES MAPPINGMETHODS SLICINGS ATTRIBUTEMETHODS DICTIONARYLITERALS MAPPINGS SPECIALATTRIBUTES ATTRIBUTES DYNAMICFEATURES METHODS SPECIALIDENTIFIERS ... ``` ### Impact This misalignment affects the readability of the output, making it a bit more difficult to quickly scan through it. ### Proposed Solutions I see two simple options to address this issue, but I’m open to any other suggestions as well: 1. **Increase the line width to 88 characters**: To preserve the default four columns, a minimum width of 88 characters would be required to ensure each item, including `"ASSIGNMENTEXPRESSIONS"`, fits within its column: ``` ASSERTION DEBUGGING LITERALS SEQUENCES ASSIGNMENT DELETION LOOPING SHIFTING ASSIGNMENTEXPRESSIONS DICTIONARIES MAPPINGMETHODS SLICINGS ATTRIBUTEMETHODS DICTIONARYLITERALS MAPPINGS SPECIALATTRIBUTES ATTRIBUTES DYNAMICFEATURES METHODS SPECIALIDENTIFIERS ... ``` 2. **Reduce the number of columns to 3** (Recommendation): Reducing the column count to 3 when listing topics would provide enough space for longer topic names (up to 25 characters). This solution is preferred for compatibility with many terminals that default to 80 characters per line: ``` ASSERTION EXCEPTIONS PACKAGES ASSIGNMENT EXECUTION POWER ASSIGNMENTEXPRESSIONS EXPRESSIONS PRECEDENCE ATTRIBUTEMETHODS FLOAT PRIVATENAMES ATTRIBUTES FORMATTING RETURNING ... ``` ### 🙂 <!-- gh-linked-prs --> ### Linked PRs * gh-125226 * gh-134225 * gh-134226 <!-- /gh-linked-prs -->
b22460c44d1bc597c96d4a3d27ad8373d7952820
ee36db550076e5a9185444ffbc53eaf8157ef04c
python/cpython
python__cpython-125267
# test_importlib test_multiprocessing_pool_circular_import() fails randomly on Thread sanitizer (free-threading) on GitHub Actions Example: https://github.com/python/cpython/actions/runs/11263361511/job/31321078076?pr=125219 ``` 0:01:54 load avg: 4.86 [ 9/22/1] test_importlib failed (1 failure) (1 min 35 sec) -- running (2): test_io (1 min 20 sec), test_queue (1 min 3 sec) test test_importlib failed -- Traceback (most recent call last): File "/home/runner/work/cpython/cpython/Lib/test/test_importlib/test_threaded_import.py", line 255, in test_multiprocessing_pool_circular_import script_helper.assert_python_ok(fn) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^ File "/home/runner/work/cpython/cpython/Lib/test/support/script_helper.py", line 182, in assert_python_ok return _assert_python(True, *args, **env_vars) File "/home/runner/work/cpython/cpython/Lib/test/support/script_helper.py", line 167, in _assert_python res.fail(cmd_line) ~~~~~~~~^^^^^^^^^^ File "/home/runner/work/cpython/cpython/Lib/test/support/script_helper.py", line 80, in fail raise AssertionError(f"Process return code is {exitcode}\n" ...<10 lines>... f"---") AssertionError: Process return code is 66 command line: ['/home/runner/work/cpython/cpython/python', '-X', 'faulthandler', '-I', '/home/runner/work/cpython/cpython/Lib/test/test_importlib/partial/pool_in_threads.py'] stdout: --- --- stderr: --- --- ``` <!-- gh-linked-prs --> ### Linked PRs * gh-125267 * gh-125305 <!-- /gh-linked-prs -->
b12e99261e656585ffbaa395af7c5dbaee5ad1ad
c1913effeed4e4da4d5310a40ab518945001ffba
python/cpython
python__cpython-125209
# Build failure on MSVC 1935 with JIT enabled # Bug report ### Bug description: Building on MSVC 1935 currently fails when building with the JIT, because that compiler does not support empty array initializers (`{}`). ```python PCbuild\build.bat --experimental-jit -c Release ... C:\actions-runner\_work\benchmarking\benchmarking\cpython\PCbuild\obj\314amd64_PGInstrument\pythoncore\jit_stencils.h(23145,68): error C2059: syntax error: '}' (compiling source file ..\Python\jit.c) [C:\actions-runner\_work\benchmarking\benchmarking\cpython\PCbuild\pythoncore.vcxproj] ``` This line in `jit_stencils.h` looks like: ``` static const StencilGroup trampoline = {emit_trampoline, 273, 24, {}}; ^ ``` This was introduced recently in #123872. All of the uses of empty initializers should use `{0}` instead. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-125209 <!-- /gh-linked-prs -->
c8fd4b12e3db49d795de55f74d9bac445c059f1b
f8ba9fb2ce6690d2dd05b356583e8e4790badad7
python/cpython
python__cpython-125322
# CTypes test failed, complex double problem # Bug report ### Bug description: Python binary has been built in the standard way: ``` ./configure --with-pydebug && make -j ``` But test_ctypes fails: ``` -> % ./python -m unittest -v test.test_ctypes.test_libc.LibTest.test_csqrt test_csqrt (test.test_ctypes.test_libc.LibTest.test_csqrt) ... FAIL ====================================================================== FAIL: test_csqrt (test.test_ctypes.test_libc.LibTest.test_csqrt) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/mikhail.efimov/projects/cpython/Lib/test/test_ctypes/test_libc.py", line 30, in test_csqrt self.assertEqual(lib.my_csqrt(4), 2+0j) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: (5e-324+6.95324111713477e-310j) != (2+0j) ---------------------------------------------------------------------- Ran 1 test in 0.001s FAILED (failures=1) ``` System: ``` -> % cat /etc/issue Debian GNU/Linux 10 \n \l ``` GCC: ``` -> % gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 8.3.0 (Debian 8.3.0-6) ``` I've tried to fix it by myself but the result has not been achieved in a reasonable amount of time. There is a simple test I've provided: ``` -> % cat test_csqrt.c #include <complex.h> #include <stdio.h> int complex my_csqrt(double complex a) { double complex z1 = a; double complex z2 = csqrt(a); printf("my_csqrt (%.10f%+.10fi) = %.10f%+.10fi\n", creal(z1), cimag(z1), creal(z2), cimag(z2)); return 0; } int main() { my_csqrt(4.0); my_csqrt(4.0+4.0j); my_csqrt(-1+0.01j); my_csqrt(-1-0.01j); return 0; } ``` ``` -> % gcc -lm test_csqrt.c -o test_csqrt && ./test_csqrt my_csqrt (4.0000000000+0.0000000000i) = 2.0000000000+0.0000000000i my_csqrt (4.0000000000+4.0000000000i) = 2.1973682269+0.9101797211i my_csqrt (-1.0000000000+0.0100000000i) = 0.0049999375+1.0000124996i my_csqrt (-1.0000000000-0.0100000000i) = 0.0049999375-1.0000124996i ``` So, it's not a problem in my libc version. Moreover, this problem can be reproduced with standard libm.so (/lib/x86_64-linux-gnu/libm-2.28.so): ``` -> % cat ctypes_fix/test.py import ctypes libm = ctypes.CDLL('libm.so.6') libm.clog.restype = ctypes.c_double_complex libm.clog.argtypes = ctypes.c_double_complex, clog_5 = libm.clog(5.0) clog_1000_2j = libm.clog(1000.0+2j) print(f"{clog_5=}") print(f"{clog_1000_2j=}") ``` ``` -> % ./python ctypes_fix/test.py clog_5=(5e-324+6.9529453382261e-310j) clog_1000_2j=(5e-324+6.9529453382261e-310j) ``` IMHO, some problem lies in using ctypes.c_double_complex as an argument and return value types. FYI, with double argtype and restype clog works like classical double log: ``` -> % cat ctypes_fix/test2.py import ctypes libm = ctypes.CDLL('libm.so.6') libm.clog.restype = ctypes.c_double libm.clog.argtypes = ctypes.c_double, clog_5 = libm.clog(5.0) clog_1000 = libm.clog(1000.0) print(f"{clog_5=}") print(f"{clog_1000=}") ``` ``` -> % ./python ctypes_fix/test2.py clog_5=1.6094379124341003 clog_1000=6.907755278982137 ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-125322 * gh-126104 * gh-132865 * gh-135932 * gh-135973 <!-- /gh-linked-prs -->
aac89b54c5ee03c4d64fbdfbb6ea3001e26aa83a
54c6fcbefd33a8d8bf8c004cf1aad3be3d37b933
python/cpython
python__cpython-125199
# Use the public PyUnicodeWriter API Replace `PyUnicode_New()`, `PyUnicode_CopyCharacters()`, etc. with `PyUnicodeWriter`. It avoids creating incomplete Unicode strings: see [Avoid creating incomplete/invalid objects](https://github.com/capi-workgroup/api-evolution/issues/36). <!-- gh-linked-prs --> ### Linked PRs * gh-125199 * gh-125201 * gh-125202 * gh-125214 * gh-125219 * gh-125220 * gh-125222 * gh-125227 * gh-125242 * gh-125249 * gh-125262 * gh-125270 * gh-125271 * gh-125458 * gh-125528 <!-- /gh-linked-prs -->
9bda7750c2af779d3431f5ea120db91c6c83ec49
f978fb4f8d6eac0585057e463bb1701dc04a9900
python/cpython
python__cpython-125251
# "Immortal" objects aren't immortal and that breaks things. # Bug report ### Bug description: [Immortal](https://dictionary.cambridge.org/us/dictionary/english/immortal) objects should live forever. By definition, immortality is a permanent property of an object; if it can loose immortality, then it wasn't immortal in the first place. Immortality allows some useful optimizations and safety guarantees that can make CPython faster *and* more robust. Which would be great, if we didn't play fast and loose with immortality. For no good reason that I'm aware of there are two functions `_Py_ClearImmortal` and `_Py_SetMortal` that make immortal objects mortal. This is nonsense. We must remove these functions. We have also added `_Py_IsImmortalLoose` because it is too easy for C-extensions Instead of adding these workarounds, we need to fix this problem as well. Let's fix immortality so that we can rely on it and take advantage of it. ### CPython versions tested on: 3.12, 3.13, CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-125251 * gh-127797 * gh-127860 * gh-127863 * gh-131184 * gh-131230 * gh-131355 <!-- /gh-linked-prs -->
c9014374c50d6ef64786d3e7d9c7e99053d5c9e2
01fc3b34cc6994bc83b6540da3a8573e79dfbb56
python/cpython
python__cpython-125183
# Spelling Error # Documentation In the Doc folder, library subfolder, in the document `__future__.rst` (`Doc/library/__future__.rst`) there is a spelling error in the sentence: “PEP 649: Deferred evalutation of annotations using descriptors” Evalutation should be evaluation. <!-- gh-linked-prs --> ### Linked PRs * gh-125183 <!-- /gh-linked-prs -->
e0835aff2e45629ee85af642190e79e4061312b5
6b533a659bc8df04daa194d827604dcae14d5801
python/cpython
python__cpython-125303
# Make `pthread_self()` return a non-zero value in `thread_pthread_stubs.h` Currently our stub for `pthread_self()` (used by WASI) just returns zero: https://github.com/python/cpython/blob/37228bd16e3ef97d32da08848552f7ef016d68ab/Python/thread_pthread_stubs.h#L106-L109 I propose we return a non-zero value for better consistency with functional pthread implementations. For example: ```c PyAPI_FUNC(pthread_t) pthread_self(void) { return (pthread_t)(uintptr_t)&py_tls_entries; } ``` ### Why? We occasionally assume that `PyThread_get_thread_ident_ex()` returns a non-zero value. For example: * https://github.com/python/cpython/issues/110455 * In `_PyRecursiveMutex` for the owner field (oops) We can work around these issues with `#ifndef HAVE_PTHREAD_STUBS` or by fixing the `_PyRecursiveMutex` implementation, but I think we might save ourselves a few headaches in the future by just making the `pthread_self()` stub behave a bit more like actual pthread implementations. cc @brettcannon @kumaraditya303 <!-- gh-linked-prs --> ### Linked PRs * gh-125303 <!-- /gh-linked-prs -->
08489325d1cd94eba97c5f5f8cac49521fd0b0d7
022c50d190e14affb952a244c4eb6e4a644ad0c9
python/cpython
python__cpython-125151
# test_fma_zero_result fails due to unexpected zero instead of negative zero on NetBSD # Bug report ### Bug description: ```sh home$ ./python -m test test_math -m test_fma_zero_result ``` ```python Using random seed: 4191327291 0:00:00 load avg: 0.57 Run 1 test sequentially in a single process 0:00:00 load avg: 0.57 [1/1] test_math test test_math failed -- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_math.py", line 2773, in test_fma_zero_result self.assertIsNegativeZero(math.fma(x-y, x+y, -z)) ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/blue/cpython/Lib/test/test_math.py", line 2876, in assertIsNegativeZero self.assertTrue( ~~~~~~~~~~~~~~~^ value == 0 and math.copysign(1, value) < 0, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ msg="Expected a negative zero, got {!r}".format(value) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ AssertionError: False is not true : Expected a negative zero, got 0.0 test_math failed (1 failure) == Tests result: FAILURE == 1 test failed: test_math Total duration: 358 ms Total tests: run=1 (filtered) failures=1 Total test files: run=1/1 (filtered) failed=1 Result: FAILURE home$ ``` **OS:** NetBSD 10.0 ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-125151 * gh-125173 <!-- /gh-linked-prs -->
92760bd85b8f48b88df5b81100a757048979de83
e0c87c64b1cb4112ed5cfc1ae84ff8e48b1c0340
python/cpython
python__cpython-125143
# For new REPL the help page should explain keyboard shortcuts # Feature or enhancement ### Proposal: It would be nice if the help you see when typing `help` in the new REPL would mention the keyboard shortcuts. ### 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-125143 * gh-135215 <!-- /gh-linked-prs -->
68a737691b0fd591de00f4811bb23a5c280fe859
31a500a92b1baf49a21d15b6b5fc0b6095f1e305
python/cpython
python__cpython-125212
# Python 3.13.0 REPL loads local files unexpectedly, causing conflicts and security issues # Bug report ### Bug description: ## Description When starting the Python 3.13.0 REPL in a directory containing a file named `code.py`, the REPL attempts to load this local file instead of the standard library `code` module. This causes conflicts and errors when initializing the interactive environment. This is also a **major** security issue. ## Steps to Reproduce 1. Create a directory and navigate to it 2. Create a file named `code.py` in this directory 3. Ensure Python 3.13.0 is installed (e.g., using pyenv) 4. Start the Python 3.13.0 REPL in this directory ## Expected Behavior The Python REPL should start normally, using the standard library `code` module for its interactive features. ## Actual Behavior The REPL fails to initialize properly, producing an error message indicating that it's attempting to use the local `code.py` file instead of the standard library module: ```pytb aleksa@aleksa:~/testing13$ python Python 3.13.0 (main, Oct 8 2024, 16:45:05) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. Failed calling sys.__interactivehook__ Traceback (most recent call last): File "<frozen site>", line 498, in register_readline File "/home/aleksa/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/readline.py", line 39, in <module> from . import commands, historical_reader File "/home/aleksa/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/historical_reader.py", line 26, in <module> from .reader import Reader File "/home/aleksa/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/reader.py", line 32, in <module> from . import commands, console, input File "/home/aleksa/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/console.py", line 153, in <module> class InteractiveColoredConsole(code.InteractiveConsole): ^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'code' has no attribute 'InteractiveConsole' (consider renaming '/home/aleksa/testing13/code.py' since it has the same name as the standard library module named 'code' and the import system gives it precedence) warning: can't use pyrepl: module 'code' has no attribute 'InteractiveConsole' (consider renaming '/home/aleksa/testing13/code.py' since it has the same name as the standard library module named 'code' and the import system gives it precedence) >>> ``` ## Additional Context - This behavior is not observed in Python 3.12.7 - The issue seems to be related to how Python 3.13.0 handles module imports in the REPL initialization process ## System Information - OS: Linux (Ubuntu 22.04) - Python version: 3.13.0 - Installation method: pyenv ## Possible Solution The REPL initialization process should be modified to ensure it uses the standard library `code` module, regardless of local files in the current directory. ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-125212 * gh-125224 <!-- /gh-linked-prs -->
c7d5d1d93b630e352abd9a0c93ea6d34c443f444
1877543d03d323d581b5fc0f19eff501926ba151
python/cpython
python__cpython-125144
# `_thread.RLock.release` is not safe in free-threaded builds Similar to #117721, `_thread.RLock.release` is not safe in free-threaded builds, it should be changed to use `_PyRecursiveMutex`. cc @colesbury <!-- gh-linked-prs --> ### Linked PRs * gh-125144 <!-- /gh-linked-prs -->
67f6e08147bc005e460d82fcce85bf5d56009cf5
5217328f93f599755bd70418952392c54f705a71
python/cpython
python__cpython-125169
# struct module has undefined behavior when loading bools # Bug report ### Bug description: https://github.com/python/cpython/blob/a5fc50994a3fae46d0c3d496c4e1d5e00548a1b8/Modules/_struct.c#L489-L491 Bool values are required to be either 0 or 1, but this memcpy will copy an arbitrary value to it. This produces UBSAN reports like: ``` Modules/_struct.c:491:28: runtime error: load of value 32, which is not a valid value for type 'bool' --   | #0 0x786c2573cc3e in nu_bool cpython3/Modules/_struct.c:491:28   | #1 0x786c2572fad0 in s_unpack_internal cpython3/Modules/_struct.c:1684:21   | #2 0x786c2572a1f3 in unpack_impl cpython3/Modules/_struct.c:2399:12   | #3 0x786c2572a1f3 in unpack cpython3/Modules/clinic/_struct.c.h:295:20   | #4 0x5c0517b46548 in cfunction_vectorcall_FASTCALL cpython3/Objects/methodobject.c:436:24   | #5 0x5c0516f89796 in _PyObject_VectorcallTstate cpython3/Include/internal/pycore_call.h:167:11   | #6 0x5c0516f89796 in object_vacall cpython3/Objects/call.c:819:14   | #7 0x5c0516f89c88 in PyObject_CallFunctionObjArgs cpython3/Objects/call.c:926:14   | #8 0x5c0516f4e5c3 in fuzz_struct_unpack cpython3/Modules/_xxtestfuzz/fuzzer.c:125:26   | #9 0x5c0516f4e5c3 in _run_fuzz cpython3/Modules/_xxtestfuzz/fuzzer.c:569:14   | #10 0x5c0516f4e5c3 in LLVMFuzzerTestOneInput cpython3/Modules/_xxtestfuzz/fuzzer.c:639:11   | #11 0x5c0516eb0870 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:614:13   | #12 0x5c0516e9bae5 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:327:6   | #13 0x5c0516ea157f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:862:9   | #14 0x5c0516ecc822 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10   | #15 0x786c27c3c082 in __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/libc-start.c:308:16   | #16 0x5c0516e93ccd in _start ``` (https://oss-fuzz.com/testcase-detail/5186406032080896) This should probably copy to an integer type that's the same width as `_Bool`. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-125169 * gh-125263 * gh-125265 <!-- /gh-linked-prs -->
87d7315ac57250046372b0d9ae4619ba619c8c87
e4cab488d4445e8444932f3bed1c329c0d9e5038
python/cpython
python__cpython-125424
# pdb: can't debug a script with arguments # Bug report ### Bug description: _Hello everyone,_ With Python 3.13, `pdb` doesn't pass arguments like `-b` or `--bar` to a script while it works fine with Python 3.12. <details><summary><b>test.py</b></summary> <p> ```python import sys print(' '.join(sys.argv)) ``` </p> </details> ✅ Good: ``` $ python3.13 -m pdb -c continue -c quit test.py foo test.py foo The program finished and will be restarted ``` 🐛 **Bad:** ``` $ python3.13 -m pdb -c continue -c quit test.py foo --bar usage: pdb [-h] [-c command] (-m module | pyfile) [args ...] pdb: error: unrecognized arguments: --bar ``` ✅ Good: ``` $ python3.12 -m pdb -c continue -c quit test.py foo --bar test.py foo --bar The program finished and will be restarted ``` _Best regards!_ ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-125424 * gh-125547 <!-- /gh-linked-prs -->
9c2bb7d551a695f35db953a671a2ddca89426bef
3ea488aac44887a7cdb30be69580c81a0ca6afe2
python/cpython
python__cpython-125097
# The `site` module must not load `_pyrepl` if `PYTHON_BASIC_REPL` env var is set Even if the new REPL is disabled by setting PYTHON_BASIC_REPL=1 env var, the site module still loads it. I propose to make sure that it's not loaded in this case. Moreover, PYTHON_BASIC_REPL should be ignored if -E or -I command line options are used. <!-- gh-linked-prs --> ### Linked PRs * gh-125097 * gh-125111 <!-- /gh-linked-prs -->
65ce228d63878d8b6d0005f682e89ad9d5289c4b
5967dd8a4de60a418de84d1d1d9efc063ad12c47
python/cpython
python__cpython-125085
# In "out-of-tree" build `regen-all` generates different paths # Feature or enhancement ### Proposal: In a "out-of-tree" build `regen-all` generates different paths I build CPython with my `build` directory outside of the cpython checkout: ``` dev_dir/ build/ cpython/ <- cpython repo clone ``` and then from inside `build/` I run `../cpython/configure && make` If I do a `make regen-all`, it generates paths which include the `../` into the generated code comments ex: ``` diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index a0d3072d2cd..fa43d118818 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -1,6 +1,6 @@ -// This file is generated by Tools/cases_generator/opcode_metadata_generator.py +// This file is generated by /<dev_dir>/projects/python/build/../cpython/Tools/cases_generator/opcode_metadata_generator.py // from: -// Python/bytecodes.c +// ../cpython/Python/bytecodes.c // Do not edit! #ifndef Py_CORE_OPCODE_METADATA_H ``` ### 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-125085 <!-- /gh-linked-prs -->
7dca7322cca7ff146444e56f28f21f1090987fff
fca552993da32044165223eec2297b6aaaac60ad
python/cpython
python__cpython-125074
# Assignment expressions are missing from auto-generated topics # Documentation Assignment expressions are missing from the auto-generated topics file. This can be seen by regenerating the file with `make pydoc-topics`. <!-- gh-linked-prs --> ### Linked PRs * gh-125074 * gh-125077 <!-- /gh-linked-prs -->
447a15190d6d766004b77619ba43e44256e348e2
a7f0727ca575fef4d8891b5ebfe71ef2a774868b
python/cpython
python__cpython-125156
# Pathlib join pure windows path and pure posix path changes it behaviour on 3.13 # Bug report ### Bug description: ## 3.12.7 ``` Python 3.12.7 (main, Oct 8 2024, 00:39:14) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pathlib; pathlib.PureWindowsPath("C:\\A") / pathlib.PurePosixPath("/foo/C:\\B").relative_to("/") PureWindowsPath('C:/B') ``` ## 3.13.0rc3 ``` Python 3.13.0rc3 (main, Oct 7 2024, 23:18:57) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pathlib; pathlib.PureWindowsPath("C:\\A") / pathlib.PurePosixPath("/foo/C:\\B").relative_to("/") PureWindowsPath('C:/A/foo/C:/B') ``` Not sure if it is a bug, or a fixed behaviour ### CPython versions tested on: 3.12, 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-125156 * gh-125409 * gh-125410 <!-- /gh-linked-prs -->
cb8e5995d89d9b90e83cf43310ec50e177484e70
c6d7b644c2425b397cfb641f336bea70eb8a329a
python/cpython
python__cpython-125064
# Emit slices as constants in the bytecode compiler # Feature or enhancement ### Proposal: Constant slices are currently emitted as multiple bytecodes by the Python bytecode compiler. For example, `x[:-2, 1:-1]` generates: ``` LOAD_CONST 4 (0) LOAD_CONST 5 (-2) BUILD_SLICE 2 LOAD_CONST 1 (1) LOAD_CONST 2 (-1) BUILD_SLICE 2 BUILD_TUPLE 2 ``` Then tuples of slices are constant like this, this could instead be compiled down to a single `LOAD_CONST` instruction: ``` LOAD_CONST 1 ((slice(0, -2, None), slice(1, -1, None)) ``` According to @fberlakovich and [Stefan Brunthaler](https://drops.dagstuhl.de/search/documents?author=Brunthaler,%20Stefan)'s paper on [Cross module quickening](https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ECOOP.2024.6), this can have a significant impact on Numpy benchmarks. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-125064 * gh-126804 * gh-126829 * gh-126830 <!-- /gh-linked-prs -->
c6127af8685c2a9b416207e46089cee79d028b85
7dca7322cca7ff146444e56f28f21f1090987fff
python/cpython
python__cpython-125141
# `_thread` module docs: update yet another bullet point in the *caveats* list # Documentation [*Note:* This issue is, in a way, a continuation of gh-125025.] Near the [end](https://docs.python.org/3.14/library/_thread.html#index-2) of the documentation of the `_thread` module there is a list of caveats. One of them – the third one – seems no longer accurate: > It is not possible to interrupt the [acquire()](https://docs.python.org/3.14/library/threading.html#threading.Lock.acquire) method on a lock — the [KeyboardInterrupt](https://docs.python.org/3.14/library/exceptions.html#KeyboardInterrupt) exception will happen after the lock has been acquired. – **whereas** it appears that (since [Python 3.2](https://docs.python.org/3.14/whatsnew/3.2.html#multi-threading)) lock acquisitions *can* be interrupted by signals, at least on platforms using Pthreads. <!-- gh-linked-prs --> ### Linked PRs * gh-125141 * gh-125306 * gh-125307 <!-- /gh-linked-prs -->
0135848059162ad81478a7776fec622d68a36524
b12e99261e656585ffbaa395af7c5dbaee5ad1ad
python/cpython
python__cpython-125042
# Re-enable skipped test_zlib tests on s390x hardware acceleration Some variants of the s390x platform have instructions for hardware-accelerated deflate compression. With HW acceleration, compressed byte stream can be different from the software implementation in zlib. (It still decompresses to the original of course.) The zlib-ng library can be built to use this, and CPython can be built with zlib-ng. In 2022 (#90781, GH-31096), two tests that failed on s390x were unconditionally skipped. IMO, it would be better if we only skip checking the compressed stream, but *do* check the round-trip result. Testing should be a bit easier now that a buildbot worker has the HW-accelerated zlib. In #107535, the `skip_on_s390x` variable was separated from the comment that explains it. I propose to name the skip condition `HW_ACCELERATED` rather than `skip_on_s390x` -- theoretically, other platforms might need this in the future. <!-- gh-linked-prs --> ### Linked PRs * gh-125042 * gh-125526 * gh-125527 * gh-125577 * gh-125585 * gh-125587 <!-- /gh-linked-prs -->
cc5a225cdc2a5d4e035dd08d59cef39182c10a6c
fcef3fc9a593e2aa868d23cf2d91c57d8bf60ac6
python/cpython
python__cpython-125071
# `this_instr` should be const in generated code. `this_instr` is generated, and should be `const`. # Bug report ### Bug description: We currently generate ```C _Py_CODEUNIT *this_instr =... ``` we should generate ```C _Py_CODEUNIT* const this_instr =... ``` to prevent it being accidentally changed. ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-125071 <!-- /gh-linked-prs -->
6b533a659bc8df04daa194d827604dcae14d5801
3024b16d51bb7f74177c5a5038cc9a56fd2b26bd
python/cpython
python__cpython-125026
# `_thread` module docs: remove/update certain bullet points in the *caveats* list # Documentation Near the [end ](https://docs.python.org/3.14/library/_thread.html#index-2)of the documentation of the `_thread` module there is a list of *caveats*. It looks like it was written a long time ago and some of its items seem no longer accurate... We can read that: * [in the first bullet point] > Threads interact strangely with interrupts: the [KeyboardInterrupt](https://docs.python.org/3.14/library/exceptions.html#KeyboardInterrupt) exception will be received by an arbitrary thread. (When the [signal](https://docs.python.org/3.14/library/signal.html#module-signal) module is available, interrupts always go to the main thread.) **whereas** it seems that nowadays we could replace that text with a much simpler statement: > Interrupts always go to the main thread (the [KeyboardInterrupt](https://docs.python.org/3.14/library/exceptions.html#KeyboardInterrupt) exception will be received by that thread). * [in the last bullet point] > When the main thread exits, it does not do any of its usual cleanup (except that [try](https://docs.python.org/3.14/reference/compound_stmts.html#try) … [finally](https://docs.python.org/3.14/reference/compound_stmts.html#finally) clauses are honored), and the standard I/O files are not flushed. **whereas** it seems just not true anymore. I believe this bullet point should be removed entirely. Here, I address a request to a core developer who is an expert in threading _**to confirm or correct my change suggestions presented above.**_ [EDIT: see [the related PR](https://github.com/python/cpython/pull/125026)] *** See also: https://discuss.python.org/t/are-all-descriptions-of-the-caveats-listed-near-the-end-of-thread-modules-docs-up-to-date/55261/18 (this response by @eryksun is concise and clear, so I suggest *TL;DR-readers* to focus on it – as some other parts of that discussion thread are not well focused on the questions from the original post). <!-- gh-linked-prs --> ### Linked PRs * gh-125026 * gh-125031 * gh-125032 <!-- /gh-linked-prs -->
1e098dc766ba4f29a63da4f188fb214af7623365
feca4cf64e9742b9c002d5533ced47e68b34a880
python/cpython
python__cpython-125027
# `importlib` documentation doesn't declare functions properly https://docs.python.org/3/library/importlib.metadata.html#distribution-versions doesn't actually define a Sphinx function for `version`, so attempted references with `` `:func:`importlib.metadata.version` `` (including via the `intersphinx` extension) fail. Edit: fixed the backticks thanks to @serhiy-storchaka's tip below (TIL that you can use repeated backticks with trailing and leading space for inline code markup, allowing inclusion of single backticks in the quoted code) <!-- gh-linked-prs --> ### Linked PRs * gh-125027 * gh-125047 * gh-125048 * gh-125050 * gh-125055 * gh-125080 <!-- /gh-linked-prs -->
cda3b5a576412a8671bbe4c68bb792ec14f1a4b1
d8f707420b3b0975567e0d9cab60c978d6cb7111
python/cpython
python__cpython-125636
# Segfault on ``cls.__dict__['__new__'].__annotations__`` # Crash report ### What happened? The following is a reproducer of (another) segfault discovered when trying to test Python 3.14 in CI for Sphinx: ```python class Spam: def __new__(cls, x, y): pass if __name__ == '__main__': assert Spam.__new__.__annotations__ == {} obj = Spam.__dict__['__new__'] assert isinstance(obj, staticmethod) getattr(obj, '__annotations__', None) # segfault here try: obj.__annotations__ # and here (absent the above) except AttributeError: pass print('no segfault!') ``` Whilst checking `__annotations__` directly is somewhat convoluted, it was originally triggered by `inspect.isasyncgenfunction()`, which calls `inspect._signature_is_functionlike()` via `_has_code_flag()`. A similar error occurs with `__class_getitem__` and `__init_subclass__`, but not with user-defined methdods declared with either `classmethod` or `staticmethod`. As the reproducer demonstrates, the segfault only happens with the descriptor object from `__dict__` -- `cls.__new__.__annotations__` is fine. Bisection showed this to be due to d28afd3fa064db10a2eb2a65bba33e8ea77a8fcf (#119864), cc @JelleZijlstra ```text d28afd3fa064db10a2eb2a65bba33e8ea77a8fcf is the first bad commit commit d28afd3fa064db10a2eb2a65bba33e8ea77a8fcf Author: Jelle Zijlstra <jelle.zijlstra@gmail.com> Date: Fri May 31 14:05:51 2024 -0700 gh-119180: Lazily wrap annotations on classmethod and staticmethod (#119864) ``` A ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.14.0a0 (bisect/bad:d28afd3fa06, Oct 6 2024, 01:35:23) [GCC 13.2.0] <!-- gh-linked-prs --> ### Linked PRs * gh-125636 * gh-125664 <!-- /gh-linked-prs -->
c3164ae3cf4e8f9ccc4df8ea5f5664c5927ea839
d8c864816121547338efa43c56e3f75ead98a924
python/cpython
python__cpython-125015
# Heap-use-after-free READ 8 · dictkeys_decref in fuzz_ast_literal_eval # Crash report ### What happened? From: https://oss-fuzz.com/testcase-detail/5876542813569024 Introduced in: https://github.com/python/cpython/compare/29a1a6e3ed6f606939b4aaf8d6955f368c3be3fc...43cd7aa8cd88624f7211e47b98bc1e8e63e7660f [reproducer.txt](https://github.com/user-attachments/files/17267182/reproducer.txt) ``` >>> s = open("reproducer.txt").read() >>> ast.literal_eval(s) ================================================================= ==11615==ERROR: AddressSanitizer: heap-use-after-free on address 0x62f000046410 at pc 0x000100fa9760 bp 0x00016f290780 sp 0x00016f290778 READ of size 8 at 0x62f000046410 thread T0 #0 0x100fa975c in Py_DECREF refcount.h:342 #1 0x100fc9c88 in dictkeys_decref dictobject.c:458 #2 0x100fb8db8 in dict_dealloc dictobject.c:3199 #3 0x1010235bc in _Py_Dealloc object.c:2893 #4 0x1012659e4 in ast_dealloc Python-ast.c:5052 #5 0x1010b4ffc in subtype_dealloc typeobject.c:2572 #6 0x1010235bc in _Py_Dealloc object.c:2893 #7 0x101267c00 in ast_repr_max_depth Python-ast.c #8 0x101017744 in PyObject_Repr object.c:694 #9 0x101317d70 in _PyEval_EvalFrameDefault generated_cases.c.h:3248 #10 0x1012f2bf0 in _PyObject_VectorcallTstate pycore_call.h:167 #11 0x1012eeef8 in map_next bltinmodule.c:1442 #12 0x100e5f368 in iternext abstract.c:2874 #13 0x100e5aef8 in PyIter_Next abstract.c:2924 #14 0x10108c200 in set_update_iterable_lock_held setobject.c:971 #15 0x1010804ac in make_new_set setobject.c:1095 #16 0x100ea92cc in _PyObject_VectorcallTstate pycore_call.h:167 #17 0x10132e20c in _PyEval_EvalFrameDefault generated_cases.c.h:921 #18 0x1013029d8 in PyEval_EvalCode ceval.c:647 #19 0x1012f7b68 in builtin_exec bltinmodule.c.h:556 #20 0x10131ccd8 in _PyEval_EvalFrameDefault generated_cases.c.h:1451 #21 0x1013029d8 in PyEval_EvalCode ceval.c:647 #22 0x1012f7b68 in builtin_exec bltinmodule.c.h:556 #23 0x101004360 in cfunction_vectorcall_FASTCALL_KEYWORDS methodobject.c:441 #24 0x100ea92cc in _PyObject_VectorcallTstate pycore_call.h:167 #25 0x10132e20c in _PyEval_EvalFrameDefault generated_cases.c.h:921 #26 0x100eabb64 in _PyVectorcall_Call call.c:273 #27 0x1015e1fe0 in pymain_run_module main.c:349 #28 0x1015e3048 in pymain_run_stdin main.c:574 #29 0x1015e07fc in Py_RunMain main.c:775 #30 0x1015e1894 in pymain_main main.c:805 #31 0x1015e1c30 in Py_BytesMain main.c:829 #32 0x19bf60270 (<unknown module>) 0x62f000046410 is located 16 bytes inside of 49104-byte region [0x62f000046400,0x62f0000523d0) freed by thread T0 here: #0 0x102b84d40 in free+0x98 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x54d40) #1 0x1010235bc in _Py_Dealloc object.c:2893 #2 0x101267c00 in ast_repr_max_depth Python-ast.c #3 0x1012675e0 in ast_repr_max_depth Python-ast.c:5799 #4 0x101017744 in PyObject_Repr object.c:694 #5 0x101317d70 in _PyEval_EvalFrameDefault generated_cases.c.h:3248 #6 0x1012f2bf0 in _PyObject_VectorcallTstate pycore_call.h:167 #7 0x1012eeef8 in map_next bltinmodule.c:1442 #8 0x100e5f368 in iternext abstract.c:2874 #9 0x100e5aef8 in PyIter_Next abstract.c:2924 #10 0x10108c200 in set_update_iterable_lock_held setobject.c:971 #11 0x1010804ac in make_new_set setobject.c:1095 #12 0x100ea92cc in _PyObject_VectorcallTstate pycore_call.h:167 #13 0x10132e20c in _PyEval_EvalFrameDefault generated_cases.c.h:921 #14 0x1013029d8 in PyEval_EvalCode ceval.c:647 #15 0x1012f7b68 in builtin_exec bltinmodule.c.h:556 #16 0x10131ccd8 in _PyEval_EvalFrameDefault generated_cases.c.h:1451 #17 0x1013029d8 in PyEval_EvalCode ceval.c:647 #18 0x1012f7b68 in builtin_exec bltinmodule.c.h:556 #19 0x101004360 in cfunction_vectorcall_FASTCALL_KEYWORDS methodobject.c:441 #20 0x100ea92cc in _PyObject_VectorcallTstate pycore_call.h:167 #21 0x10132e20c in _PyEval_EvalFrameDefault generated_cases.c.h:921 #22 0x100eabb64 in _PyVectorcall_Call call.c:273 #23 0x1015e1fe0 in pymain_run_module main.c:349 #24 0x1015e3048 in pymain_run_stdin main.c:574 #25 0x1015e07fc in Py_RunMain main.c:775 #26 0x1015e1894 in pymain_main main.c:805 #27 0x1015e1c30 in Py_BytesMain main.c:829 #28 0x19bf60270 (<unknown module>) previously allocated by thread T0 here: #0 0x102b84c04 in malloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x54c04) #1 0x10105eb7c in _PyMem_DebugRawAlloc obmalloc.c:2699 #2 0x100f75aa8 in _PyLong_New longobject.c:157 #3 0x100f95138 in long_from_binary_base longobject.c:2586 #4 0x100f84a30 in PyLong_FromString longobject.c:3052 #5 0x100b78d78 in parsenumber_raw pegen.c #6 0x100b75984 in _PyPegen_number_token pegen.c:704 #7 0x100c037a4 in atom_rule parser.c:14845 #8 0x100bfa8c4 in primary_rule parser.c:14262 #9 0x100bf8068 in await_primary_rule parser.c:14216 #10 0x100bf625c in power_rule parser.c:14092 #11 0x100bf1a14 in factor_rule parser.c:14042 #12 0x100bedfe8 in term_raw parser.c:13883 #13 0x100bec1f8 in term_rule parser.c:13626 #14 0x100be69e8 in sum_rule parser.c:13458 #15 0x100be3e04 in shift_expr_rule parser.c:13278 #16 0x100be19c4 in bitwise_and_rule parser.c:13156 #17 0x100bdfb48 in bitwise_xor_rule parser.c:13034 #18 0x100bd9084 in bitwise_or_rule parser.c:12912 #19 0x100c30b5c in comparison_rule parser.c:12152 #20 0x100c2f660 in inversion_rule parser.c:12103 #21 0x100c2bc80 in conjunction_rule parser.c:11980 #22 0x100c10584 in disjunction_rule parser.c:11892 #23 0x100bd34ac in expression_rule parser.c:11180 #24 0x100cb0914 in kvpair_rule parser.c:16890 #25 0x100caed4c in double_starred_kvpair_rule parser.c:16850 #26 0x100ca9890 in double_starred_kvpairs_rule parser.c:16778 #27 0x100c82d0c in _tmp_96_rule parser.c:31587 #28 0x100c04c18 in atom_rule parser.c:14908 #29 0x100bfa8c4 in primary_rule parser.c:14262 SUMMARY: AddressSanitizer: heap-use-after-free refcount.h:342 in Py_DECREF Shadow bytes around the buggy address: 0x62f000046180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x62f000046200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x62f000046280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x62f000046300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x62f000046380: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x62f000046400: fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd 0x62f000046480: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x62f000046500: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x62f000046580: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x62f000046600: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x62f000046680: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==11615==ABORTING fish: Job 1, './python.exe' terminated by signal SIGABRT (Abort) ~/p/cpython ❯❯❯ ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ ### Output from running 'python -VV' on the command line: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-125015 <!-- /gh-linked-prs -->
a1be83dae311e4a1a6e66ed5e128b1ad8794f72f
3fc673e97dafb8a73ee99937cf2bf0b849b1f418
python/cpython
python__cpython-125013
# Tokenize does not roundtrip {{ after \n # Bug report ### Bug description: ```python import tokenize, io source_code = r''' f"""{80 * '*'}\n{{test}}{{details}}{{test2}}\n{80 * '*'}""" ''' tokens = tokenize.generate_tokens(io.StringIO(source_code).readline) x = tokenize.untokenize((t,s) for t, s, *_ in tokens) print(x) ``` Expected: ``` f"""{80 *'*'}\n{{test}}{{details}}{{test2}}\n{80 *'*'}""" ``` Got: ``` f"""{80 *'*'}\n{test}}{{details}}{{test2}}\n{80 *'*'}""" ``` Note the absence of a second { in the {{ after the \n — but in no other positions. Unlike some other roundtrip failures of tokenize, some of which are minor infelicities, this one actually creates a syntactically invalid program on roundtrip, which is quite bad. You get a `SyntaxError: f-string: single '}' is not allowed` when trying to use the results. ### CPython versions tested on: 3.12 ### Operating systems tested on: Linux, Windows <!-- gh-linked-prs --> ### Linked PRs * gh-125013 * gh-125020 * gh-125021 <!-- /gh-linked-prs -->
db23b8bb13863fcd88ff91bc22398f8e0312039e
39c859f6ffd8dee7f48b2181c6cb59cffe8125ff
python/cpython
python__cpython-125861
# Documenting that the new (3.14) `pathlib` copy functionality uses Copy-on-Write # Documentation (edited) The PR [119058](https://github.com/python/cpython/pull/119058) and [122369](https://github.com/python/cpython/pull/122369) added `pathlib.Path.copy()`, with Copy-on-Write support. CoW should be documented, because it has distinctive, user-requested properties on huge files. * Copying is instantaneous, does negligible I/O, requires no disk space for the data and negligible disk space for the metadata. * Reading the original and the copy does half the I/O and requires half the RAM (page cache) than a traditional copy (think booting VM images) In the context of a Linux VM manager, CoW is an explicit desired property. Disk image copying is the slowest part of snapshotting a VM. Users expect CoW snapshots nowadays, and intentionally set up a CoW filesystem for the disk image directory. For clarity, I'm not asking to mention `FICLONE` specifically. I'm not asking to mention `copy_file_range`, a micro-optimization on the traditional copy algorithm. Instead, my point is that switching from O(file size) to zero is a user-visible feature. Keywords: reflink copy <!-- gh-linked-prs --> ### Linked PRs * gh-125861 <!-- /gh-linked-prs -->
ff8349979c2ca4e442afc583e1217519611c6c48
8525c9375f25e6ec0c0b5dfcab464703f6e78082
python/cpython
python__cpython-124993
# Segfault on Python 3.13.0rc3 (free-threaded) with `requests` # Crash report ### What happened? Reproducer: ```python import queue import threading import requests class HyperlinkAvailabilityCheckWorker(threading.Thread): def __init__(self, rqueue, wqueue) -> None: self.rqueue = rqueue self.wqueue = wqueue self._session = requests.Session() super().__init__(daemon=True) def run(self) -> None: while True: uri = self.wqueue.get() if not uri: self._session.close() break self._session.request( 'HEAD', url=uri, timeout=30, verify=True, ) self.rqueue.put(uri) self.wqueue.task_done() def test_crash(): for i in range(1_000): print(f'loop: {i}') # setup rqueue = queue.Queue() wqueue = queue.Queue() workers: list[HyperlinkAvailabilityCheckWorker] = [] # invoke threads num_workers = 2 for _ in range(num_workers): thread = HyperlinkAvailabilityCheckWorker(rqueue, wqueue) thread.start() workers.append(thread) # check total_links = 0 for hyperlink in ( 'https://python.org/dev/', 'https://peps.python.org/pep-0008/', ): wqueue.put(hyperlink, False) total_links += 1 done = 0 while done < total_links: result = rqueue.get() print(result) done += 1 # shutdown_threads wqueue.join() for _worker in workers: wqueue.put('', False) if __name__ == '__main__': import sys print(f'GIL enabled?: {sys._is_gil_enabled()}') print() test_crash() ``` Sample output: ```text GIL enabled?: False loop: 0 https://peps.python.org/pep-0008/ https://python.org/dev/ loop: 1 https://peps.python.org/pep-0008/ https://python.org/dev/ loop: 2 https://peps.python.org/pep-0008/ https://python.org/dev/ loop: 3 Fatal Python error: Segmentation fault Thread 0x00007f3dc5e00640 (most recent call first): File "/usr/lib/python3.13/ssl.py", line 513 in set_alpn_protocols File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/util/ssl_.py", line 467 in ssl_wrap_socket File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/connection.py", line 909 in _ssl_wrap_socket_and_match_hostname File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/connection.py", line 730 in connect File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/connectionpool.py", line 1095 in _validate_conn File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/connectionpool.py", line 466 in _make_request File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/connectionpool.py", line 789 in urlopen File "/home/runner/venv-3.13/lib/python3.13t/site-packages/requests/adapters.py", line 667 in send File "/home/runner/venv-3.13/lib/python3.13t/site-packages/requests/sessions.py", line 703 in send File "/home/runner/venv-3.13/lib/python3.13t/site-packages/requests/sessions.py", line 589 in request File "/home/runner/work/sphinx/sphinx/./tests/test_build.py", line 21 in run File "/usr/lib/python3.13/threading.py", line 1041 in _bootstrap_inner File "/usr/lib/python3.13/threading.py", line 1012 in _bootstrap Current thread 0x00007f3dbfe00640 (most recent call first): File "/usr/lib/python3.13/ssl.py", line 1372 in do_handshake File "/usr/lib/python3.13/ssl.py", line 1076 in _create File "/usr/lib/python3.13/ssl.py", line 455 in wrap_socket File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/util/ssl_.py", line 513 in _ssl_wrap_socket_impl File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/util/ssl_.py", line 469 in ssl_wrap_socket File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/connection.py", line 909 in _ssl_wrap_socket_and_match_hostname File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/connection.py", line 730 in connect File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/connectionpool.py", line 1095 in _validate_conn File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/connectionpool.py", line 466 in _make_request File "/home/runner/venv-3.13/lib/python3.13t/site-packages/urllib3/connectionpool.py", line 789 in urlopen File "/home/runner/venv-3.13/lib/python3.13t/site-packages/requests/adapters.py", line 667 in send File "/home/runner/venv-3.13/lib/python3.13t/site-packages/requests/sessions.py", line 703 in send File "/home/runner/venv-3.13/lib/python3.13t/site-packages/requests/sessions.py", line 589 in request File "/home/runner/work/sphinx/sphinx/./tests/test_build.py", line 21 in run File "/usr/lib/python3.13/threading.py", line 1041 in _bootstrap_inner File "/usr/lib/python3.13/threading.py", line 1012 in _bootstrap Thread 0x00007f3dc9140000 (most recent call first): File "/usr/lib/python3.13/threading.py", line 359 in wait File "/usr/lib/python3.13/queue.py", line 202 in get File "/home/runner/work/sphinx/sphinx/./tests/test_build.py", line 58 in test_crash File "/home/runner/work/sphinx/sphinx/./tests/test_build.py", line 73 in <module> /home/runner/work/_temp/f534164e-5195-4157-abd9-f2f4e6fed6dd.sh: line 5: 2783 Segmentation fault (core dumped) python -u ./tests/test_build.py ``` @JelleZijlstra ran this on macOS with the following lldb traceback: ```text (lldb) bt * thread #6, stop reason = signal SIGABRT * frame #0: 0x0000000194852a60 libsystem_kernel.dylib`__pthread_kill + 8 frame #1: 0x000000019488ac20 libsystem_pthread.dylib`pthread_kill + 288 frame #2: 0x0000000194797a30 libsystem_c.dylib`abort + 180 frame #3: 0x00000001946a7dc4 libsystem_malloc.dylib`malloc_vreport + 896 frame #4: 0x00000001946ab430 libsystem_malloc.dylib`malloc_report + 64 frame #5: 0x00000001946c5494 libsystem_malloc.dylib`find_zone_and_free + 528 frame #6: 0x0000000100871448 libssl.3.dylib`SSL_CTX_set_alpn_protos + 180 frame #7: 0x000000010075e5d0 _ssl.cpython-313t-darwin.so`_ssl__SSLContext__set_alpn_protocols [inlined] _ssl__SSLContext__set_alpn_protocols_impl(self=0x0000028ca0798f30, protos=0x0000000172eaa3e0) at _ssl.c:3381:9 [opt] frame #8: 0x000000010075e59c _ssl.cpython-313t-darwin.so`_ssl__SSLContext__set_alpn_protocols(self=0x0000028ca0798f30, arg=<unavailable>) at _ssl.c.h:528:20 [opt] frame #9: 0x0000000100066354 python`method_vectorcall_O(func=0x0000028ca09bec90, args=0x00000001005ecc20, nargsf=<unavailable>, kwnames=<unavailable>) at descrobject.c:475:24 [opt] frame #10: 0x00000001000585d0 python`PyObject_Vectorcall [inlined] _PyObject_VectorcallTstate(tstate=0x000000010380a600, callable=0x0000028ca09bec90, args=<unavailable>, nargsf=<unavailable>, kwnames=<unavailable>) at pycore_call.h:168:11 [opt] frame #11: 0x00000001000585a8 python`PyObject_Vectorcall(callable=0x0000028ca09bec90, args=<unavailable>, nargsf=<unavailable>, kwnames=<unavailable>) at call.c:327:12 [opt] frame #12: 0x0000000100194098 python`_PyEval_EvalFrameDefault(tstate=<unavailable>, frame=<unavailable>, throwflag=<unavailable>) at generated_cases.c.h:813:23 [opt] ``` ```text python(84085,0x172eab000) malloc: *** error for object 0x600000840000: pointer being freed was not allocated python(84085,0x172eab000) malloc: *** set a breakpoint in malloc_error_break to debug ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux, macOS ### Output from running 'python -VV' on the command line: Python 3.13.0rc3+ experimental free-threading build (main, Oct 4 2024, 08:50:03) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-124993 * gh-125780 <!-- /gh-linked-prs -->
4c53b2577531c77193430cdcd66ad6385fcda81f
2a378dba987e125521b678364f0cd44b92dd5d52
python/cpython
python__cpython-124974
# locale.nl_langinfo(locale.ALT_DIGITS) does not work ALT_DIGITS is a glibc specific item. It is supported by Python (there is an explicit list of supported items), but the result is not correct. From [The GNU C Library Reference Manual](https://sourceware.org/glibc/manual/latest/html_node/The-Elegant-and-Fast-Way.html): > ALT_DIGITS > > The return value is a representation of up to 100 values used to represent the values 0 to 99. As for ERA this value is not intended to be used directly, but instead indirectly through the strftime function. When the modifier O is used in a format which would otherwise use numerals to represent hours, minutes, seconds, weekdays, months, or weeks, the appropriate value for the locale is used instead. This value is only defined in few locales: az_IR, fa_IR, ja_JP, lzh_TW, my_MM, or_IN, shn_MM. But Python returns only one digit. ```pycon >>> import locale >>> locale.setlocale(locale.LC_TIME, 'ja_JP') 'ja_JP' >>> locale.setlocale(locale.LC_CTYPE, 'ja_JP') 'ja_JP' >>> locale.nl_langinfo(locale.ALT_DIGITS) '〇' ``` This is because `nl_langinfo(ALT_DIGITS)` in C returns a string with embedded null characters. How should we fix it? * return a single string with 99 embedded null characters * return a 100-tuple of strings What should we return if the value is not defined (in most locales) -- empty string (current behavior), empty tuple or None? cc @methane <!-- gh-linked-prs --> ### Linked PRs * gh-124974 * gh-125177 * gh-125232 * gh-125284 * gh-125774 * gh-125804 * gh-125805 <!-- /gh-linked-prs -->
dcc4fb2c9068f60353f0c0978948b7681f7745e6
5ca4e34bc1aab8321911aac6d5b2b9e75ff764d8
python/cpython
python__cpython-124971
# Leftover rst markup in the Compiler design internal document # Documentation The Compiler design document contains some leftover rst markup, which was probably missed when the document was migrated from the dev guide: https://github.com/python/cpython/blob/5e9e50612eb27aef8f74a0ccc234e5cfae50c4d7/InternalDocs/compiler.md?plain=1#L327-L334 The code block should be converted to use Markdown syntax. <!-- gh-linked-prs --> ### Linked PRs * gh-124971 <!-- /gh-linked-prs -->
994051e086b9ce624a3b16750d6f692bc4a3b07b
bd393aedb84a7d84d11a996bcbbf57cad90af7db
python/cpython
python__cpython-124999
# `barry_as_FLUFL` future flag does not work in new REPL # Bug report New REPL: ```python >>> from __future__ import barry_as_FLUFL >>> 1 <> 2 File "<python-input-1>", line 1 1 <> 2 ^^ SyntaxError: invalid syntax ``` Old REPL: ```python >>> from __future__ import barry_as_FLUFL >>> 1 <> 2 True ``` I understand that this is just an easter egg :) <!-- gh-linked-prs --> ### Linked PRs * gh-124999 * gh-125475 <!-- /gh-linked-prs -->
6a08a753b702ac63c9b6ac58dd204d1fe9662e9d
5f4e5b598cab86d5fd5727d423c9728221889ed0
python/cpython
python__cpython-124959
# refcycles in exceptions raised from asyncio.TaskGroup # Bug report ### Bug description: asyncio.TaskGroup attempts to avoid refcycles in raised exceptions by deleting `self._errors` but when I reviewed the code it doesn't actually achieve this: see https://github.com/python/cpython/blob/5e9e50612eb27aef8f74a0ccc234e5cfae50c4d7/Lib/asyncio/taskgroups.py#L152-L156 There's a refcycle in `me is me.__traceback__.tb_next.tb_frame.f_locals["me"]` I wrote a few tests to route out all the refcycles in tracebacks ```python import asyncio import gc import unittest class TestTaskGroup(unittest.IsolatedAsyncioTestCase): async def test_exception_refcycles_direct(self): """Test that TaskGroup doesn't keep a reference to the raised ExceptionGroup""" tg = asyncio.TaskGroup() exc = None class _Done(Exception): pass try: async with tg: raise _Done except ExceptionGroup as e: exc = e self.assertIsNotNone(exc) self.assertListEqual(gc.get_referrers(exc), []) async def test_exception_refcycles_errors(self): """Test that TaskGroup deletes self._errors, and __aexit__ args""" tg = asyncio.TaskGroup() exc = None class _Done(Exception): pass try: async with tg: raise _Done except* _Done as excs: exc = excs.exceptions[0] self.assertIsInstance(exc, _Done) self.assertListEqual(gc.get_referrers(exc), []) async def test_exception_refcycles_parent_task(self): """Test that TaskGroup deletes self._parent_task""" tg = asyncio.TaskGroup() exc = None class _Done(Exception): pass async def coro_fn(): async with tg: raise _Done try: async with asyncio.TaskGroup() as tg2: tg2.create_task(coro_fn()) except* _Done as excs: exc = excs.exceptions[0].exceptions[0] self.assertIsInstance(exc, _Done) self.assertListEqual(gc.get_referrers(exc), []) async def test_exception_refcycles_propagate_cancellation_error(self): """Test that TaskGroup deletes propagate_cancellation_error""" tg = asyncio.TaskGroup() exc = None try: async with asyncio.timeout(-1): async with tg: await asyncio.sleep(0) except TimeoutError as e: exc = e.__cause__ self.assertIsInstance(exc, asyncio.CancelledError) self.assertListEqual(gc.get_referrers(exc), []) async def test_exception_refcycles_base_error(self): """Test that TaskGroup deletes self._base_error""" class MyKeyboardInterrupt(KeyboardInterrupt): pass tg = asyncio.TaskGroup() exc = None try: async with tg: raise MyKeyboardInterrupt except MyKeyboardInterrupt as e: exc = e self.assertIsNotNone(exc) self.assertListEqual(gc.get_referrers(exc), []) ``` in writing all these tests I noticed refcycles in PyFuture: https://github.com/python/cpython/blob/58f7763b88d4e81662b9d212f6beddcb42437fe3/Lib/asyncio/futures.py#L197-L198 https://github.com/python/cpython/blob/58f7763b88d4e81662b9d212f6beddcb42437fe3/Lib/asyncio/futures.py#L215-L216 ```python class BaseFutureTests: def test_future_cancelled_result_refcycles(self): f = self._new_future(loop=self.loop) f.cancel() exc = None try: f.result() except asyncio.CancelledError as e: exc = e self.assertIsNotNone(exc) self.assertListEqual(gc.get_referrers(exc), []) def test_future_cancelled_exception_refcycles(self): f = self._new_future(loop=self.loop) f.cancel() exc = None try: f.exception() except asyncio.CancelledError as e: exc = e self.assertIsNotNone(exc) self.assertListEqual(gc.get_referrers(exc), []) ``` ### CPython versions tested on: 3.12, 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-124959 * gh-125463 * gh-125466 * gh-125486 <!-- /gh-linked-prs -->
e99650b80ace3893c2a80b3f2a4aca99cb305191
187580d95c8339a3b6e2b012f98d86101c346cfa
python/cpython
python__cpython-124957
# `_csv.c`: many temp macros do not use `#undef` # Bug report This does not cause any real problems right now, but it can in some point, out of bad luck. Consider this as a small refactoring, not a bug. <!-- gh-linked-prs --> ### Linked PRs * gh-124957 <!-- /gh-linked-prs -->
51d426dc033ef9208c0244a569f3e816e4c328c9
d1453f60c2d289d74d535874e07741745b023c90
python/cpython
python__cpython-124945
# Add socket.SO_ORIGINAL_DST # Feature or enhancement ### Proposal: The `SO_ORIGINAL_DST` should be available through the sockets module. I realize its not part of the standard BSD interface, but Cpython does include other linux-specific socket options such as `SO_VM_SOCKETS_*`. Further, it has been a source of annoyance for at least 1 other person https://groups.google.com/g/comp.lang.python/c/l4I-27iGwH4. ### 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-124945 <!-- /gh-linked-prs -->
1bffd7a2a738506a4ad50c6c3c2c32926cce6d14
2a5cdb251674ce8d9a824c102f7cd846d944cfa4
python/cpython
python__cpython-124933
# Cross builds: distinguish between installation prefix and host prefix in configure.ac? In Emscripten and wasi builds, and presumably for other cross builds, the build file system and the host file system look different. It's natural to want to install into `cross-build/$TARGET/lib` and then mount that as `/lib` in the host file system. `wasi.py` has to mess around with setting `PYTHONPATH` because `prefix` is set to a path from the build machine. I think it would simplify this if we distinguish between * `prefix` -- the path in the build file system where we want to install the files * `host_prefix` -- the path in the host file system where getpath.c will look for the files And similarly for `exec_prefix` and `host_exec_prefix`. cc @brettcannon @freakboy3742 <!-- gh-linked-prs --> ### Linked PRs * gh-124933 <!-- /gh-linked-prs -->
b1f13bce62ff666f59286e8325011d8e9e0ddca7
6742f14dfd3fa8ba8a245efa21a4f723160d93d4
python/cpython
python__cpython-124929
# Emscripten node support: Clean up old node <= 16 flags configure.ac has a bunch of `HOSTRUNNER` configuration that tries to work out what `--experimental` flags to pass to the node runtime. Most of these are only needed for node <= 16. Node 16 has been end of life since October of 2023. We should remove these. <!-- gh-linked-prs --> ### Linked PRs * gh-124929 <!-- /gh-linked-prs -->
dc2552d429c91310b0c410c3e856728d8866b05f
85799f1ffd5f285ef93a608b0aaf6acbb464ff9d
python/cpython
python__cpython-125001
# high CPU usage and freezing in Python REPL with half space character (U+200C) # Bug report ### Bug description: When entering comments in Python's REPL that contain a Half Space character (U+200C) the REPL experiences 100% CPU usage and becomes unresponsive (freezes) when using the up arrow to retrieve previous code line * https://unicode-explorer.com/c/200C ### Steps to Reproduce: 1. Go to Python REPL 2. Paste the following lines (for Windows, use F3 to activate paste mode): ```python # Half space ‌text # Up arrow key ``` 3. Press the up arrow key to navigate back to the previous line (# Half space ‌text) (If it doesn't work for you, go to the end of the line # Up arrow key and press the up button. It should freeze now. You can use Ctrl+C to interrupt the program, which resolves the freeze.) <hr> in terminal this looks like this: ``` >>> # Half space \u200ctext ... # Up arrow key ``` This problem also exists in Windows when using F3 (to active the paste mode): <img src="https://github.com/user-attachments/assets/ef7f9f53-da92-4027-88f0-211f28cfc3a8" alt="image" width="400"/> In Linux no need to active paste mode: <img src="https://github.com/user-attachments/assets/ce0253b6-e8d4-4d5d-98e0-2727b3b926bb" alt="image" width="400"/> <img src="https://github.com/user-attachments/assets/3a4f7243-f4c6-478f-867f-837b65c8c20b" alt="image" width="400"/> I can't check if this problem exists on previous python version because they break each line so i cant use up arrow to go to the previous line. Half Space character is often used in Persian and I think in other languages that utilize right-to-left . It helps in adjusting the spacing between characters for better readability <hr> Also a small note: when I use the half space at the end and no text **after** it, there is no problem: ```python # Half space ‌ # Up arrow key ``` in terminal: ``` >>> # Half space \u200c ... # Up arrow key ``` ### System Information: * Linux: Python 3.13.0rc2 | Fedora 40 * Windows Python 3.13.0rc3 | Windows 11 ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux, Windows <!-- gh-linked-prs --> ### Linked PRs * gh-125001 * gh-131061 <!-- /gh-linked-prs -->
6ab5c4aa05bf35832a3ccd1e71b28b8475fa30f4
a931a8b32415f311008dbb3f09079aae1e6d7a3d
python/cpython
python__cpython-124918
# `os.path.exists` and `lexists` no longer allow a keyword argument on Windows # Bug report ### Bug description: Historically `os.path.exists` and `os.path.lexists` have accepted their argument as a keyword, `path=`. However, in 3.13 on Windows (#118755) these functions were reimplemented in C and the C functions only accept a positional argument. This was detected by typeshed CI (python/typeshed#12730). Probably doesn't have a lot of practical effect (why would you use keyword arguments for these functions?), but it's better to keep this consistent. I'll send a PR. ### CPython versions tested on: 3.13 ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-124918 * gh-125332 * gh-125334 <!-- /gh-linked-prs -->
cc2938a18967c9d462ebb18bc09f73e4364aa7d2
a00221e5a70e54a281ba0e2cff8d85cd37ae305f
python/cpython
python__cpython-124893
# Remove redundant artificial rules and functions for them in parser.c file # Feature or enhancement ### Proposal: It seems like PEG parser produces more than one artificial rule for the same grammar rule. For example, on each gather rule (','.NAME+) in Grammar/python.gram a function '_gather_N_rule' will be generated. But only one implementation of such function makes sense, others are just redundant. Some simple changes in Tools/peg_generator/pegen/c_generator.py file should be made. We can save artificial rules in cache by Node string representation as a key instead of Node object itself. Total count of artificial rules can be lowered from 283 to 170 with this change, size of parser.c file can be lowered from 1.5 megabytes to 1.3 megabytes without any cost. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-124893 * gh-125816 <!-- /gh-linked-prs -->
1f9025a4e7819bb4f7799784710f0f3750a9ca31
e6dd71da3acc21edcc205d024d18004c7a3c7f45
python/cpython
python__cpython-130602
# race condition in threading when interpreter finalized while daemon thread runs (thread sanitizer identified) # Bug report ### Bug description: Using the code in #105805 with the newly added `test.test_threading.ThreadTests.test_finalize_daemon_thread_hang` test enabled you can reproduce this thread sanitizer crash as follows (I used clang 18): This also happens if I just take the new test and corresponding Modules/_testcapimodule.c change and patch it on top of `main` - it's a pre-existing bug not related to my PR adding the new test. _(Filing now before I check this in decorated to be skipped under sanitizers so I can reference the issue number in a comment)_ ``` CC=clang LD=lld ./configure --with-thread-sanitizer --with-pydebug && make -j8 ./python -m test test_threading -v ... ====================================================================== FAIL: test_finalize_daemon_thread_hang (test.test_threading.ThreadTests.test_finalize_daemon_thread_hang) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/greg/oss/cpython/Lib/test/test_threading.py", line 1236, in test_finalize_daemon_thread_hang assert_python_ok("-c", script) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^ File "/home/greg/oss/cpython/Lib/test/support/script_helper.py", line 182, in assert_python_ok return _assert_python(True, *args, **env_vars) File "/home/greg/oss/cpython/Lib/test/support/script_helper.py", line 167, in _assert_python res.fail(cmd_line) ~~~~~~~~^^^^^^^^^^ File "/home/greg/oss/cpython/Lib/test/support/script_helper.py", line 80, in fail raise AssertionError(f"Process return code is {exitcode}\n" ...<10 lines>... f"---") AssertionError: Process return code is 66 command line: ['/home/greg/oss/b/python', '-X', 'faulthandler', '-I', '-c', "\nimport os\nimport sys\nimport threading\nimport time\nimport _testcapi\n\nlock = threa ding.Lock()\nlock.acquire()\nthread_started_event = threading.Event()\ndef thread_func():\n try:\n thread_started_event.set()\n _testcapi.finalize_t hread_hang(lock.acquire)\n finally:\n # Control must not reach here.\n os._exit(2)\n\nt = threading.Thread(target=thread_func)\nt.daemon = True\nt.s tart()\nthread_started_event.wait()\n# Sleep to ensure daemon thread is blocked on `lock.acquire`\n#\n# Note: This test is designed so that in the unlikely case that \n# `0.1` seconds is not sufficient time for the thread to become\n# blocked on `lock.acquire`, the test will still pass, it just\n# won't be properly testing the th read behavior during\n# finalization.\ntime.sleep(0.1)\n\ndef run_during_finalization():\n # Wake up daemon thread\n lock.release()\n # Sleep to give the da emon thread time to crash if it is going\n # to.\n #\n # Note: If due to an exceptionally slow execution this delay is\n # insufficient, the test will st ill pass but will simply be\n # ineffective as a test.\n time.sleep(0.1)\n # If control reaches here, the test succeeded.\n os._exit(0)\n\n# Replace sys. stderr.flush as a way to run code during finalization\norig_flush = sys.stderr.flush\ndef do_flush(*args, **kwargs):\n orig_flush(*args, **kwargs)\n if not sys .is_finalizing:\n return\n sys.stderr.flush = orig_flush\n run_during_finalization()\n\nsys.stderr.flush = do_flush\n\n# If the follow exit code is reta ined, `run_during_finalization`\n# did not run.\nsys.exit(1)\n"] stdout: --- --- stderr: --- ================== WARNING: ThreadSanitizer: data race (pid=2184927) Write of size 8 at 0x724800000028 by main thread: #0 __tsan_memset <null> (python+0xdc23d) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #1 fill_mem_debug /home/greg/oss/b/../cpython/Objects/obmalloc.c:2637:5 (python+0x31bc3a) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #2 _PyMem_DebugRawFree /home/greg/oss/b/../cpython/Objects/obmalloc.c:2766:5 (python+0x31bc3a) #3 PyMem_RawFree /home/greg/oss/b/../cpython/Objects/obmalloc.c:971:5 (python+0x319498) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #4 free_threadstate /home/greg/oss/b/../cpython/Python/pystate.c:1455:9 (python+0x54ba27) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #5 _PyThreadState_DeleteList /home/greg/oss/b/../cpython/Python/pystate.c:1933:9 (python+0x54ba27) #6 _Py_Finalize /home/greg/oss/b/../cpython/Python/pylifecycle.c:2043:5 (python+0x522649) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #7 Py_Exit /home/greg/oss/b/../cpython/Python/pylifecycle.c:3390:9 (python+0x5253a5) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #8 handle_system_exit /home/greg/oss/b/../cpython/Python/pythonrun.c:635:9 (python+0x550ae6) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #9 _PyErr_PrintEx /home/greg/oss/b/../cpython/Python/pythonrun.c:644:5 (python+0x550ae6) #10 PyErr_PrintEx /home/greg/oss/b/../cpython/Python/pythonrun.c:721:5 (python+0x55027c) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #11 PyErr_Print /home/greg/oss/b/../cpython/Python/pythonrun.c:727:5 (python+0x55027c) #12 _PyRun_SimpleStringFlagsWithName /home/greg/oss/b/../cpython/Python/pythonrun.c:552:9 (python+0x55027c) #13 pymain_run_command /home/greg/oss/b/../cpython/Modules/main.c:253:11 (python+0x58f2e4) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #14 pymain_run_python /home/greg/oss/b/../cpython/Modules/main.c:687:21 (python+0x58f2e4) #15 Py_RunMain /home/greg/oss/b/../cpython/Modules/main.c:775:5 (python+0x58f2e4) #16 pymain_main /home/greg/oss/b/../cpython/Modules/main.c:805:12 (python+0x58f8e9) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #17 Py_BytesMain /home/greg/oss/b/../cpython/Modules/main.c:829:12 (python+0x58f969) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #18 main /home/greg/oss/b/../cpython/Programs/python.c:15:12 (python+0x15e810) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) Previous atomic read of size 8 at 0x724800000028 by thread T1: #0 _Py_atomic_load_uintptr_relaxed /home/greg/oss/b/../cpython/Include/cpython/pyatomic_gcc.h:347:10 (python+0x4de525) (BuildId: f07474199a50b9dfeeb5b474be4e3a40 79af30a5) #1 _Py_eval_breaker_bit_is_set /home/greg/oss/b/../cpython/Include/internal/pycore_ceval.h:307:19 (python+0x4de525) #2 drop_gil /home/greg/oss/b/../cpython/Python/ceval_gil.c:259:9 (python+0x4de525) #3 _PyEval_ReleaseLock /home/greg/oss/b/../cpython/Python/ceval_gil.c:596:5 (python+0x4de6fb) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #4 detach_thread /home/greg/oss/b/../cpython/Python/pystate.c:2144:5 (python+0x54c1ec) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #5 _PyThreadState_Detach /home/greg/oss/b/../cpython/Python/pystate.c:2150:5 (python+0x548adb) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #6 PyEval_SaveThread /home/greg/oss/b/../cpython/Python/ceval_gil.c:640:5 (python+0x4de922) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #7 PyThread_acquire_lock_timed_with_retries /home/greg/oss/b/../cpython/Python/thread.c:148:13 (python+0x573cbc) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30 a5) #8 acquire_timed /home/greg/oss/b/../cpython/Modules/_threadmodule.c:737:12 (python+0x61dbc0) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #9 lock_PyThread_acquire_lock /home/greg/oss/b/../cpython/Modules/_threadmodule.c:793:22 (python+0x61dbc0) #10 cfunction_call /home/greg/oss/b/../cpython/Objects/methodobject.c:540:18 (python+0x2e9488) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #11 _PyObject_MakeTpCall /home/greg/oss/b/../cpython/Objects/call.c:242:18 (python+0x2539d2) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #12 _PyObject_VectorcallTstate /home/greg/oss/b/../cpython/Include/internal/pycore_call.h:165:16 (python+0x2532ed) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af 30a5) #13 PyObject_CallNoArgs /home/greg/oss/b/../cpython/Objects/call.c:106:12 (python+0x2531bd) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #14 finalize_thread_hang /home/greg/oss/b/../cpython/Modules/_testcapimodule.c:3332:5 (_testcapi.cpython-314d-x86_64-linux-gnu.so+0x1e204) (BuildId: 4bdac866b639 cba10e0265b34477a0f6dd6d394c) #15 cfunction_vectorcall_O /home/greg/oss/b/../cpython/Objects/methodobject.c:512:24 (python+0x2e873d) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #16 _PyObject_VectorcallTstate /home/greg/oss/b/../cpython/Include/internal/pycore_call.h:167:11 (python+0x25328b) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af 30a5) #17 PyObject_Vectorcall /home/greg/oss/b/../cpython/Objects/call.c:327:12 (python+0x2549a0) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #18 _PyEval_EvalFrameDefault /home/greg/oss/b/../cpython/Python/generated_cases.c.h:920:35 (python+0x459d5a) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #19 _PyEval_EvalFrame /home/greg/oss/b/../cpython/Include/internal/pycore_ceval.h:119:16 (python+0x453c62) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #20 _PyEval_Vector /home/greg/oss/b/../cpython/Python/ceval.c:1852:12 (python+0x453c62) #21 _PyFunction_Vectorcall /home/greg/oss/b/../cpython/Objects/call.c (python+0x254ebc) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #22 _PyObject_VectorcallTstate /home/greg/oss/b/../cpython/Include/internal/pycore_call.h:167:11 (python+0x25a35b) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af 30a5) #23 method_vectorcall /home/greg/oss/b/../cpython/Objects/classobject.c:70:20 (python+0x258a85) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #24 _PyVectorcall_Call /home/greg/oss/b/../cpython/Objects/call.c:273:16 (python+0x2548a7) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #25 _PyObject_Call /home/greg/oss/b/../cpython/Objects/call.c:348:16 (python+0x254abb) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #26 PyObject_Call /home/greg/oss/b/../cpython/Objects/call.c:373:12 (python+0x254ce7) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #27 thread_run /home/greg/oss/b/../cpython/Modules/_threadmodule.c:337:21 (python+0x61c1e8) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #28 pythread_wrapper /home/greg/oss/b/../cpython/Python/thread_pthread.h:242:5 (python+0x5740bb) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) Location is heap block of size 360 at 0x724800000000 allocated by main thread: #0 calloc <null> (python+0xdeaaa) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #1 _PyMem_RawCalloc /home/greg/oss/b/../cpython/Objects/obmalloc.c:76:12 (python+0x3174cb) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #2 _PyMem_DebugRawAlloc /home/greg/oss/b/../cpython/Objects/obmalloc.c:2696:24 (python+0x31babe) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #3 _PyMem_DebugRawCalloc /home/greg/oss/b/../cpython/Objects/obmalloc.c:2741:12 (python+0x31babe) #4 PyMem_RawCalloc /home/greg/oss/b/../cpython/Objects/obmalloc.c:957:12 (python+0x3193cb) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #5 alloc_threadstate /home/greg/oss/b/../cpython/Python/pystate.c:1440:12 (python+0x549de1) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #6 new_threadstate /home/greg/oss/b/../cpython/Python/pystate.c:1549:38 (python+0x549de1) #7 _PyThreadState_New /home/greg/oss/b/../cpython/Python/pystate.c:1632:12 (python+0x54a7de) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #8 ThreadHandle_start /home/greg/oss/b/../cpython/Modules/_threadmodule.c:405:20 (python+0x61bb6a) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #9 do_start_new_thread /home/greg/oss/b/../cpython/Modules/_threadmodule.c:1882:9 (python+0x61bb6a) #10 thread_PyThread_start_joinable_thread /home/greg/oss/b/../cpython/Modules/_threadmodule.c:2005:14 (python+0x61aacc) (BuildId: f07474199a50b9dfeeb5b474be4e3a4 079af30a5) #11 cfunction_call /home/greg/oss/b/../cpython/Objects/methodobject.c:540:18 (python+0x2e9488) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #12 _PyObject_MakeTpCall /home/greg/oss/b/../cpython/Objects/call.c:242:18 (python+0x2539d2) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #13 _PyObject_VectorcallTstate /home/greg/oss/b/../cpython/Include/internal/pycore_call.h:165:16 (python+0x2532ed) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af 30a5) #14 PyObject_Vectorcall /home/greg/oss/b/../cpython/Objects/call.c:327:12 (python+0x2549a0) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #15 _PyEval_EvalFrameDefault /home/greg/oss/b/../cpython/Python/generated_cases.c.h:1831:35 (python+0x45ec3e) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #16 _PyEval_EvalFrame /home/greg/oss/b/../cpython/Include/internal/pycore_ceval.h:119:16 (python+0x453a19) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #17 _PyEval_Vector /home/greg/oss/b/../cpython/Python/ceval.c:1852:12 (python+0x453a19) #18 PyEval_EvalCode /home/greg/oss/b/../cpython/Python/ceval.c:650:21 (python+0x453a19) #19 run_eval_code_obj /home/greg/oss/b/../cpython/Python/pythonrun.c:1323:9 (python+0x55356d) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #20 run_mod /home/greg/oss/b/../cpython/Python/pythonrun.c:1408:19 (python+0x552f7e) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #21 _PyRun_StringFlagsWithName /home/greg/oss/b/../cpython/Python/pythonrun.c:1207:15 (python+0x550012) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #22 _PyRun_SimpleStringFlagsWithName /home/greg/oss/b/../cpython/Python/pythonrun.c:547:15 (python+0x550012) #23 pymain_run_command /home/greg/oss/b/../cpython/Modules/main.c:253:11 (python+0x58f2e4) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #24 pymain_run_python /home/greg/oss/b/../cpython/Modules/main.c:687:21 (python+0x58f2e4) #25 Py_RunMain /home/greg/oss/b/../cpython/Modules/main.c:775:5 (python+0x58f2e4) #26 pymain_main /home/greg/oss/b/../cpython/Modules/main.c:805:12 (python+0x58f8e9) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #27 Py_BytesMain /home/greg/oss/b/../cpython/Modules/main.c:829:12 (python+0x58f969) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #28 main /home/greg/oss/b/../cpython/Programs/python.c:15:12 (python+0x15e810) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) Thread T1 (tid=2184929, running) created by main thread at: #0 pthread_create <null> (python+0xe01ff) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #1 do_start_joinable_thread /home/greg/oss/b/../cpython/Python/thread_pthread.h:289:14 (python+0x572deb) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #2 PyThread_start_joinable_thread /home/greg/oss/b/../cpython/Python/thread_pthread.h:313:9 (python+0x572c0a) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #3 ThreadHandle_start /home/greg/oss/b/../cpython/Modules/_threadmodule.c:422:9 (python+0x61bc7b) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #4 do_start_new_thread /home/greg/oss/b/../cpython/Modules/_threadmodule.c:1882:9 (python+0x61bc7b) #5 thread_PyThread_start_joinable_thread /home/greg/oss/b/../cpython/Modules/_threadmodule.c:2005:14 (python+0x61aacc) (BuildId: f07474199a50b9dfeeb5b474be4e3a40 79af30a5) #6 cfunction_call /home/greg/oss/b/../cpython/Objects/methodobject.c:540:18 (python+0x2e9488) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #7 _PyObject_MakeTpCall /home/greg/oss/b/../cpython/Objects/call.c:242:18 (python+0x2539d2) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #8 _PyObject_VectorcallTstate /home/greg/oss/b/../cpython/Include/internal/pycore_call.h:165:16 (python+0x2532ed) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af3 0a5) #9 PyObject_Vectorcall /home/greg/oss/b/../cpython/Objects/call.c:327:12 (python+0x2549a0) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #10 _PyEval_EvalFrameDefault /home/greg/oss/b/../cpython/Python/generated_cases.c.h:1831:35 (python+0x45ec3e) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #11 _PyEval_EvalFrame /home/greg/oss/b/../cpython/Include/internal/pycore_ceval.h:119:16 (python+0x453a19) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #12 _PyEval_Vector /home/greg/oss/b/../cpython/Python/ceval.c:1852:12 (python+0x453a19) #13 PyEval_EvalCode /home/greg/oss/b/../cpython/Python/ceval.c:650:21 (python+0x453a19) #14 run_eval_code_obj /home/greg/oss/b/../cpython/Python/pythonrun.c:1323:9 (python+0x55356d) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #15 run_mod /home/greg/oss/b/../cpython/Python/pythonrun.c:1408:19 (python+0x552f7e) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #16 _PyRun_StringFlagsWithName /home/greg/oss/b/../cpython/Python/pythonrun.c:1207:15 (python+0x550012) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #17 _PyRun_SimpleStringFlagsWithName /home/greg/oss/b/../cpython/Python/pythonrun.c:547:15 (python+0x550012) #18 pymain_run_command /home/greg/oss/b/../cpython/Modules/main.c:253:11 (python+0x58f2e4) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #19 pymain_run_python /home/greg/oss/b/../cpython/Modules/main.c:687:21 (python+0x58f2e4) #20 Py_RunMain /home/greg/oss/b/../cpython/Modules/main.c:775:5 (python+0x58f2e4) #21 pymain_main /home/greg/oss/b/../cpython/Modules/main.c:805:12 (python+0x58f8e9) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #22 Py_BytesMain /home/greg/oss/b/../cpython/Modules/main.c:829:12 (python+0x58f969) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) #23 main /home/greg/oss/b/../cpython/Programs/python.c:15:12 (python+0x15e810) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) SUMMARY: ThreadSanitizer: data race (/home/greg/oss/b/python+0xdc23d) (BuildId: f07474199a50b9dfeeb5b474be4e3a4079af30a5) in __tsan_memset ================== ThreadSanitizer: reported 1 warnings ``` Examining the code in question where the race occurs... it's this block https://github.com/python/cpython/blob/v3.13.0rc3/Python/ceval_gil.c#L258 ```c #ifdef FORCE_SWITCHING /* We might be releasing the GIL for the last time in this thread. In that case there's a possible race with tstate->interp getting deleted after gil->mutex is unlocked and before the following code runs, leading to a crash. We can use final_release to indicate the thread is done with the GIL, and that's the only time we might delete the interpreter. See https://github.com/python/cpython/issues/104341. */ if (!final_release && _Py_eval_breaker_bit_is_set(tstate, _PY_GIL_DROP_REQUEST_BIT)) ``` looping in @ericsnowcurrently for #104341 context. The `int final_release` value in that call stack is 0 so the next bit tries to load the eval breaker bit but the thread was woken up by python code executing **during finalization of the main thread** per the test. How'd thread T1 ever obtain the GIL upon waking up in the first place given finalization had started? ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-130602 * gh-130649 * gh-130687 * gh-135793 <!-- /gh-linked-prs -->
cc17307faaa248535c65f6a7668e06dc8ef04575
038e4d606bdc3e38f74514ae3ddfdc7a48b7b19e
python/cpython
python__cpython-127101
# Intermittent timerfd failure on Android # Bug report This happens quite often, but usually doesn't cause a buildbot failure because it passes on the second attempt. However, it's now double-failed twice: * https://buildbot.python.org/#/builders/1594/builds/54 * https://buildbot.python.org/#/builders/1594/builds/141 ``` ====================================================================== FAIL: test_timerfd_poll (test.test_os.TimerfdTests.test_timerfd_poll) ---------------------------------------------------------------------- Traceback (most recent call last): File "/data/user/0/org.python.testbed/files/python/lib/python3.14/test/test_os.py", line 4390, in test_timerfd_poll self.check_timerfd_poll(False) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ File "/data/user/0/org.python.testbed/files/python/lib/python3.14/test/test_os.py", line 4378, in check_timerfd_poll self.assertEqual(self.read_count_signaled(fd), 1) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: 2 != 1 ---------------------------------------------------------------------- Ran 367 tests in 12.334s FAILED (failures=1, skipped=120) test test_os failed ``` <!-- gh-linked-prs --> ### Linked PRs * gh-127101 * gh-127105 * gh-127279 * gh-127290 <!-- /gh-linked-prs -->
4ca2c82862e3810a7d68799df2bb5198a9afb219
3c7a90a83146dc6e55f6f9ecd9af0bf9682f98a6
python/cpython
python__cpython-124952
# remove_unreachable: Assertion `target->b_predecessors == 0 || target == b->b_next' failed # Crash report ### What happened? The following code causes an assertion in a cpython debug build ```python name_3=5 name_2=2 name_1=0 while name_3 <= name_2 > name_1: try: raise except: pass finally: pass ``` output (Python 3.13.0a5+): ```python python3: Python/flowgraph.c:994: remove_unreachable: Assertion `target->b_predecessors == 0 || target == b->b_next' failed. ``` The bug is in the current 3.13 branch. I bisected the problem down to 04697bcfaf5dd34c9312f4f405083b6d33b3511f @iritkatriel I think this is again one for you. Little side note. I found this bug after fuzzing for ~3 days. I want to start to test the cpython main branch in the future and I hope to find bugs like this earlier. ### CPython versions tested on: 3.13 ### Operating systems tested on: _No response_ ### Output from running 'python -VV' on the command line: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-124952 * gh-124977 <!-- /gh-linked-prs -->
f474391b26aa9208b44ca879f8635409d322f738
994051e086b9ce624a3b16750d6f692bc4a3b07b
python/cpython
python__cpython-124859
# asyncio.open_connection happy_eyeballs_delay leaves refcycles with exception tracebacks # Bug report ### Bug description: ```python import asyncio import gc import objgraph import weakref async def amain(): exc = None try: await asyncio.open_connection( host="localhost", port=8080, happy_eyeballs_delay=0.25 ) except* OSError as excs: exc = excs.exceptions[0] assert exc is not None print(gc.get_referrers(exc)) asyncio.run(amain()) ``` should be empty but you get a bunch of exceptions lists: ``` [[ConnectionRefusedError(111, "Connect call failed ('127.0.0.1', 8080)")], [ConnectionRefusedError(111, "Connect call failed ('127.0.0.1', 8080)")]] ``` ### CPython versions tested on: 3.12, 3.13, CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-124859 * gh-124912 * gh-124913 <!-- /gh-linked-prs -->
c066bf553577d1000e208eb078d9e758c3e41186
6810928927e4d12d9a5dd90e672afb096882b730
python/cpython
python__cpython-124843
# import_helper.make_legacy_pyc() works incorrectly for source files in a directory # Bug report For source file with relative path "path/to/file.py" it creates file with incorrect path "/absolute/path/to/path/to/file.pyc" instead of "path/to/file.pyc". * it adds the directory path to the source file twice. * it seems that returning an absolute path is unnecessary. Surprisingly, the broken version works in all existing tests. Either they only use the source file path without directory, or absolute path, or the test is indifferent to the compiled file path. But it did not work in #124799 which created independent set of tests for running compiled files. <!-- gh-linked-prs --> ### Linked PRs * gh-124843 * gh-124853 * gh-124854 * gh-124868 <!-- /gh-linked-prs -->
60ff67d010078eca15a74b1429caf779ac4f9c74
da1e5526aee674bb33c17a498aa3781587b9850c
python/cpython
python__cpython-124587
# Improve invalid input type handling in `tomllib.loads` # Feature or enhancement ### Proposal: `tomllib.loads` only accepts str as input. Given bytes, it throws ``` TypeError: a bytes-like object is required, not 'str' ``` This is a bubbled up exception from the `replace` method on line https://github.com/python/cpython/blob/4129a74a3772a2fa75a3b8f642f6b4cf18520e0e/Lib/tomllib/_parser.py#L74 which is otherwise fine, but the message has bytes and str the wrong way around, which can be very confusing. I propose catching the exception and raising a new TypeError with an improved message. While at it, I also propose catching any AttributeErrors from this line of code and raising the same new TypeError instead. As a result, a sensible TypeError is raised in nearly all cases where incorrect type is passed in. ### 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: Original issue report by @mechsin on Tomli's issue tracker: https://github.com/hukkin/tomli/issues/223 PR: https://github.com/python/cpython/pull/124587 <!-- gh-linked-prs --> ### Linked PRs * gh-124587 <!-- /gh-linked-prs -->
9ce90206b7a4649600218cf0bd4826db79c9a312
120729d862f0ef9979508899f7f63a9f3d9623cb
python/cpython
python__cpython-124834
# Subsequent datetime.now() calls return the same datetime # Bug report ### Bug description: Subsequent `datetime.now()` may return the same moment in time. ```python from datetime import datetime, UTC now1 = datetime.now(UTC) for i in range(10_000): a = i now2 = datetime.now(UTC) assert now1 < now2 ``` ``` assert now1 < now2 ^^^^^^^^^^^ AssertionError ``` This does seem to work as expected: ```python from time import sleep from datetime import datetime, UTC now1 = datetime.now(UTC) sleep(0.000_000_001) now2 = datetime.now(UTC) assert now1 < now2 ``` I'm not sure if this is a bug, but at least it's a documentation issue. There's nothing in the [docs](https://docs.python.org/3/library/datetime.html#datetime.datetime.now) explicitly indicating this behavior. ### CPython versions tested on: 3.12 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-124834 * gh-125145 * gh-125146 <!-- /gh-linked-prs -->
760b1e103a0aa696cdf448e0d500cd1bac2213fa
c6127af8685c2a9b416207e46089cee79d028b85
python/cpython
python__cpython-124821
# Fix compiler warnings on JIT builds where `-mno-outline-atomics` are not supported. See https://github.com/python/cpython/actions/runs/11115927540/job/30887579831?pr=124813#step:6:1063 as an example. Related to a change I made in https://github.com/python/cpython/pull/124443/files#diff-700c6057d24addce74e8787edb5f5556f718299f6ef1742cbb1d79580cdb535cR144 <!-- gh-linked-prs --> ### Linked PRs * gh-124821 * gh-124883 <!-- /gh-linked-prs -->
6737333ac5777345d058271621ccb3c2d11dc81e
9b31a2d83fa7cb0fe4d75ce7cf6a2c9ea2ce0728
python/cpython
python__cpython-124795
# TypeAliasType with should also raise an error if non-default type parameter follows default type parameter # Bug report ### Bug description: The following statement is invalid: ```python type X[T_default=int, T] = (T_default, U) # SyntaxError: non-default type parameter 'T' follows default type parameter ``` However, writing it as a `TypeAliasType` is possible. The following should likely raise an error as well to mimic this behavior: ``` from typing import TypeAliasType, TypeVar T = TypeVar('T') T_default = TypeVar("T_default", default=int) TypeAliasType("TupleT_default_reversed", tuple[T_default, T], type_params=(T_default, T)) print("OK") ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-124795 <!-- /gh-linked-prs -->
2115d76acc14effb3dbb9fedcf21048b2ad62c5e
b3aa1b5fe260382788a2df416599325ad680a5ee
python/cpython
python__cpython-124769
# `test_class.TestInlineValues.test_detach_materialized_dict_no_memory` leaks references # Bug report ### Bug description: Refleaks tests are failing on main due to a leak from `test_class.TestInlineValues.test_detach_materialized_dict_no_memory`: ``` > ./python -m test -R 3:3 test_class --match test.test_class.TestInlineValues.test_detach_materialized_dict_no_memory Using random seed: 1105673167 0:00:00 load avg: 1.71 Run 1 test sequentially in a single process 0:00:00 load avg: 1.71 [1/1] test_class beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more) 123:456 XX1 111 test_class leaked [1, 1, 1] references, sum=3 test_class leaked [1, 1, 1] memory blocks, sum=3 test_class failed (reference leak) == Tests result: FAILURE == 1 test failed: test_class Total duration: 223 ms Total tests: run=1 (filtered) Total test files: run=1/1 (filtered) failed=1 Result: FAILURE > ``` That test was added in gh-124627. cc @markshannon @DinoV ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-124769 * gh-124777 <!-- /gh-linked-prs -->
6f4d64b048133c60d40705fb5ef776f78c7dd710
b5774603a0c877f19b33fb922e2fb967b1d50329
python/cpython
python__cpython-124721
# Update "Using Python on macOS" document for free-threading installation The existing [Using Python on a Mac](https://docs.python.org/3/using/mac.html) section of the `Python Setup and Usage` document needs to document the steps needed to install the optional free-threading interpreter support in Python 3.13. In 3.13 pre-releases, some of this information was included in either the macOS installer `ReadMe` file or in #120098. In general, the "Using" document is also extremely out-of-date so a major update to the whole document is needed to be able to add the free-threaded installation info. The PR attached to this issue does both. <!-- gh-linked-prs --> ### Linked PRs * gh-124721 * gh-124775 <!-- /gh-linked-prs -->
60181f4ed0e48ff35dc296da6b51473bfc553d16
54e29ea4eb7b54c888fd5764eef2215535e4d862
python/cpython
python__cpython-124704
# Do not raise an Exception when exiting pdb # Feature or enhancement ### Proposal: Currently, if you set a `breakpoint()` in your code, and exit with `q` or `ctrl+D`, the output is just ugly: ``` Traceback (most recent call last): File "/Users/gaotian/programs/cpython/example.py", line 11, in <module> while True: ^^^^ File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/bdb.py", line 90, in trace_dispatch return self.dispatch_line(frame) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/bdb.py", line 115, in dispatch_line if self.quitting: raise BdbQuit ^^^^^^^^^^^^^ bdb.BdbQuit ``` It makes no sense to print a trackback of an exception just because I want to quit pdb and stop debugging. Now that we have an indicator for inline mode, we can deal with this. What I propose is - for inline mode debugging, any quit attempt(`q`, `ctrl+D`, etc.) will trigger a confirm prompt (like `gdb` or `lldb`), the user can say no and go back to debugging, or they can confirm and quit the program. There are a few design details which I will list in the following PR. ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-124704 * gh-129768 * gh-129818 * gh-130286 * gh-130395 * gh-133013 <!-- /gh-linked-prs -->
7d275611f62c9008c2d90b08c9f21462f80a8328
a49225cc66680129f129d1fcf6e20afb37a1a877
python/cpython
python__cpython-124548
# Add concurrent.futures.InterpreterPoolExecutor # Feature or enhancement ### Proposal: While we wait on [PEP 734](https://peps.python.org/pep-0734/), there's nothing blocking us from adding a new executor for multiple interpreters. Doing so would allow people to start trying them out. (I wish I had thought of this for 3.13!) My planned design: * mostly built on top of `ThreadPoolExecutor` * callables (and args) passed as initializer or to `submit()` or `map()` will be pickled (same as `ProcessPoolExecutor`) * initializer and `submit()` arg can be a script instead of a callable (a script for `map()` doesn't make sense since there are no args) * `__init__()` will take a new "shared" arg that corresponds to what `Interpreter.prepare_main()` takes in PEP 734, to allow each worker interpreter to share some data In the future we could support a more efficient "sharing" scheme than pickle. When (or if) PEP 734 is accepted, we can refactor the executor to use the `interpreters` module rather than using `_interpreters` directly. Open questions: * reconstitute and raise uncaught exceptions from running in the interpreter (like we do for `ProcessPoolExecutor`)? * (optionally?) exec functions against __main__ instead of the their original module, i.e. use the body of the function as a script? CC @brianquinlan ### 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-124548 * gh-125708 * gh-134321 <!-- /gh-linked-prs -->
a5a7f5e16d8c3938d266703ea8fba8ffee3e3ae5
a38fef4439139743e3334c1d69f24cafdf4d71da
python/cpython
python__cpython-124823
# Support parsing negative scientific notation and complex numbers in argparse # Bug report Per https://github.com/python/cpython/issues/123945#issuecomment-2379781453 <!-- gh-linked-prs --> ### Linked PRs * gh-124823 <!-- /gh-linked-prs -->
0c5a48c1c9039eb1ce25a96c43505c4de0a0b9d7
52f70da19cf3c7198be37faeac233ef803080f6f
python/cpython
python__cpython-124691
# _decimal: Store a module state in objects for faster access # Feature or enhancement ### Proposal: It is known to be efficient to get a module state from an object directly rather than from a type. The same can go for the `_decimal`'s context object (i.e. extending the `PyDecContextObject` struct). Extending `PyDecObject`, which made no perf difference for me, seems to be a waste of memory with many objects. cc @vstinner @erlend-aasland @mdboom ### Links to previous discussion of this feature: * #119663 <!-- gh-linked-prs --> ### Linked PRs * gh-124691 <!-- /gh-linked-prs -->
dc12237ab092f0eee7ec5882196997804e635075
c976d789a98047ae7ddec6d13c9ea7086d9fa3f9
python/cpython
python__cpython-124683
# Intermittent test_support.test_fd_count failure on iOS # Bug report ### Bug description: An intermittent test failure has been observed on `test_support.test_fd_count`: https://buildbot.python.org/#/builders/1380/builds/1423 https://buildbot.python.org/#/builders/1380/builds/626 https://buildbot.python.org/#/builders/1380/builds/84 It's *very* intermittent - it's occurred 3 times in almost 1400 buildbot runs. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-124683 * gh-124687 <!-- /gh-linked-prs -->
10d504aecc56f9481114fe3d0a8d1721d38db7e3
e349f73a5ad2856b0a7cbe4aef7cc081c7aed777
python/cpython
python__cpython-131427
# Intermittent buildbot failure and timeout on Android aarch64 # Bug report Happened twice in the last two days: * https://buildbot.python.org/#/builders/1594/builds/84 * https://buildbot.python.org/#/builders/1594/builds/110 In both cases, the sequence of events is: * `TestAndroidOutput.test_bytes` fails due to not finding the test start marker line in the logcat. A "threading._dangling was modified" warning is also shown. * In build 84, none of the output from the first attempt of test_bytes or test_str is shown in the buildbot log, even though test_str passed. The first line of test_rate_limit is also missing ("Initial message to reset"), but the body of that test is present. * In build 110, only the test_bytes output is missing. ``` test_bytes (test.test_android.TestAndroidOutput.test_bytes) ... FAIL test_str (test.test_android.TestAndroidOutput.test_str) ... ok test_rate_limit (test.test_android.TestAndroidRateLimit.test_rate_limit) ... ok ====================================================================== FAIL: test_bytes (test.test_android.TestAndroidOutput.test_bytes) ---------------------------------------------------------------------- Traceback (most recent call last): File "/data/user/0/org.python.testbed/files/python/lib/python3.14/test/test_android.py", line 67, in assert_log line = self.logcat_queue.get(timeout=(deadline - time())) File "/data/user/0/org.python.testbed/files/python/lib/python3.14/queue.py", line 212, in get raise Empty _queue.Empty During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/data/user/0/org.python.testbed/files/python/lib/python3.14/test/test_android.py", line 57, in setUp self.assert_log("I", tag, message, skip=True, timeout=5) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/user/0/org.python.testbed/files/python/lib/python3.14/test/test_android.py", line 69, in assert_log self.fail(f"line not found: {expected!r}") ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: line not found: 'test.test_android.TestAndroidOutput.test_bytes 1727286696.2114007' ---------------------------------------------------------------------- Ran 3 tests in 5.061s FAILED (failures=1) Warning -- threading._dangling was modified by test_android Warning -- Before: {<weakref at 0x7414441df0; to 'threading._MainThread' at 0x73aea63cb0>} Warning -- After: {<weakref at 0x7414dd9d00; to 'threading._MainThread' at 0x73aea63cb0>, <weakref at 0x7414dda110; to 'threading.Thread' at 0x7414d36450>} test test_android failed ``` * The test passes on the second attempt. All output appears to be present and correct, except that the "Initial message to reset" is combined with "Line 000" because the test neglects to write a newline between them, but that's probably not relevant. * Python reports the overall result as "FAILURE then SUCESS". * But then it apparently hangs until the worker times out after "1800 seconds without output". <!-- gh-linked-prs --> ### Linked PRs * gh-131427 * gh-131433 <!-- /gh-linked-prs -->
01b5abbc53b2a9ee8d85e0518c98efce27dbd061
c1b42db9e47b76fca3c2993cb172cc4991b04839
python/cpython
python__cpython-124677
# [C API] Add private `_PyCodec_UnregisterError` to un-register custom error handlers # Feature or enhancement ### Proposal: In order to test the Codecs C API (#123343), I need to be able to un-register a custom codecs error policy, otherwise running the tests would leak since they won't clean the registry. For now, I've managed to make the tests work without this but it's an ugly hack (namely, relying on the fact that the test suite is executed multiple times when searching for refleaks). The proposed API is as follows: ```C /* Internal function in Python/internal/pycore_codecs.h */ extern int _PyCodec_UnregisterError(const char *name); /* Exposed private Python function in Modules/_codecsmodule.c */ static int _codecs__unregister_error(PyObject *module, PyObject *name); ``` It would: - return 0 if the name does not exist (converted into False at Python level) - return 1 if the name exists and was successfully removed (converted into True at Python level) - return -1 and set an exception if someone attemps to unregister a *standard* error policy (e.g., 'strict') or if the removal failed for whatever reason. The exception in the first case would be a `ValueError` while the exception in the second case would be the one raised internally (we would just propagate any exception by `PyDict_PopString`). cc @vstinner EDIT: After discussion, we decided to first make it entirely private and un-documented (documentation still exists at the code level but not in an RST file). If needs arise, we will make it public. ### 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-124677 <!-- /gh-linked-prs -->
c00964ecd508ba6ae43498017d5a3873844a058a
04c837d9d8a474777ef9c1412fbba14f0682366c
python/cpython
python__cpython-124897
# Python 3.12+ breaks backwards compatibility for logging QueueHandler with queue.SimpleQueue # Bug report ### Bug description: I think this is related to #119819 ```python import logging.config from queue import SimpleQueue q = SimpleQueue() config = { 'version': 1, 'handlers': { 'sink': { 'class': 'logging.handlers.QueueHandler', 'queue': q, }, }, 'root': { 'handlers': ['sink'], }, } logging.config.dictConfig(config) ``` ``` ValueError: Unable to configure handler 'sink' ``` SimpleQueue does not implement the full Queue interfaces thus both ````isinstance(obj, queue.Queue)```` and the queue interface check fails. Since this has been working on 3.8 - <3.12 I think the queue interface check is checking for methods that are not used at all and should be adjusted accordingly. https://github.com/python/cpython/blob/25189188bfcb48be653eb9fb3aee892f2b9539b9/Lib/logging/config.py#L500-L525 Tested with 3.12.6 ### CPython versions tested on: 3.12 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-124897 * gh-125059 * gh-125060 <!-- /gh-linked-prs -->
7ffe94fb242fd51bb07c7f0d31e94efeea3619d4
03775472cc69e150ced22dc30334a7a202fc0380
python/cpython
python__cpython-124712
# [CVE-2024-9287] `venv` activation scripts do not quote strings properly # Bug report ### Bug description: Crafted paths break the script templates: ```console envname='";uname -a;"' mkdir "$envname" cd "$envname" python3 -m venv . . ./bin/activate ``` ``` Linux archlinux 6.10.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 19 Aug 2024 17:02:39 +0000 x86_64 GNU/Linux ``` Like pypa/virtualenv#2768 the execution path itself is low-risk, but it enables many potential downstream attack vectors. Downstream projects that automatically initialize and activate `venv` at a controllable path (e.g. read from repo configuration file) could execute unexpected commands. ### CPython versions tested on: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-124712 * gh-125813 * gh-125947 * gh-126185 * gh-126269 * gh-126300 * gh-126301 <!-- /gh-linked-prs -->
d48cc82ed25e26b02eb97c6263d95dcaa1e9111b
44f841f01af0fb038e142a07f15eda1ecdd5b08a
python/cpython
python__cpython-124643
# Free-threaded dictionary lookups aren't marking objects as weakref'd # Bug report ### Bug description: Dictionaries have a fast path which doesn't lock on lookups and a slow path which does. The intention is that the fast-path will succeed after the first slow-path lookup has been passed. But currently we're not parking objects as shared so it always fails. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-124643 * gh-124798 <!-- /gh-linked-prs -->
077e7ef6a0abbf9e04b9aa11b4f621031004c31f
cce1125574f7b74343afda4bd0030706f67e13df
python/cpython
python__cpython-124700
# Please restore the loop param to staggered.staggered_race # Bug report ### Bug description: The following remove the `loop` param from `staggered.staggered_race` : https://github.com/python/cpython/pull/124390 https://github.com/python/cpython/pull/124574 https://github.com/python/cpython/pull/124573 ~~its wasn't scheduled for removal until [3.16](https://github.com/python/cpython/commit/3fbbedb0ad64eeba7284d1244158b892497d55c8#diff-44556baf5b5e0be424424f6a3058952ceef4bd6a73637f138df33e93def215f7L74)~~ this never merged ### CPython versions tested on: 3.12, 3.13, CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-124700 * gh-124744 <!-- /gh-linked-prs -->
133e929a791d209b578b4822a7a07f4570b3803b
7bdfabe2d1ec353ecdc75a5aec41cce83e572391
python/cpython
python__cpython-124629
# Pyrepl on windows is blocking where it shouldn't # Bug report ### Bug description: ReadConsoleInput is documented as always returning at least one input. This breaks things in a couple of spots: - searching inputs and hitting ctrl-c. This blocks reading, a 2nd ctrl-c is required, and then the interpreter crashes. - Background exceptions with a partial input. This should display the exception and do a keyboard interrupt, but it only happens on the next keypress. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-124629 * gh-124638 <!-- /gh-linked-prs -->
83e5dc0f4d0d8d71288f162840b36f210fb03abf
66cc6d4c502074ddbfeda1be28fae6aa4535e4a8
python/cpython
python__cpython-136822
# Use new REPL for wasm demo # Feature or enhancement ### Proposal: The WASM demo in [Tools/wasm](https://github.com/python/cpython/tree/main/Tools/wasm) was very useful for getting a Python REPL setup working in my web app. It would be wonderful if that demo could be updated to work with the new Python 3.13 REPL (pyrepl). I believe this would require a change to the way the file streams are handled (`stdin` specifically) though I'm not currently certain how to make that change. ### 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-136822 * gh-136837 * gh-136931 * gh-136935 * gh-136978 * gh-136988 * gh-136993 * gh-137004 * gh-137067 <!-- /gh-linked-prs -->
7ae4749d064bd49b0dd96172fee20c1f1678d9e9
1ba23244f3306aa8d19eb4b98cfee6ad4cf514c9
python/cpython
python__cpython-124792
# test_perf_profiler fails on Linux (both AArch64 and x86) # Bug report ### Bug description: Our CI picked up this failure recently. We are using Ubuntu 24.04 and it is failing both on AArch64 and x86. ``` $ ./python -m test test_perf_profiler -v == CPython 3.14.0a0 (heads/main-dirty:7a839d6013, Sep 26 2024, 14:53:59) [GCC 13.2.0] == Linux-6.8.0-44-generic-aarch64-with-glibc2.39 little-endian == Python build: release == cwd: /home/user/work/ce-sw/repos/cpython/build/build/test_python_worker_1359145æ == CPU count: 8 == encodings: locale=UTF-8 FS=utf-8 == resources: all test resources are disabled, use -u option to unskip tests Using random seed: 1215453149 0:00:00 load avg: 0.44 Run 1 test sequentially in a single process 0:00:00 load avg: 0.44 [1/1] test_perf_profiler test_pre_fork_compile (test.test_perf_profiler.TestPerfProfiler.test_pre_fork_compile) ... skipped 'Unwinding is unreliable with frame pointers' test_python_calls_appear_in_the_stack_if_perf_activated (test.test_perf_profiler.TestPerfProfiler.test_python_calls_appear_in_the_stack_if_perf_activated) ... skipped 'Unwinding is unreliable with frame pointers' test_python_calls_do_not_appear_in_the_stack_if_perf_deactivated (test.test_perf_profiler.TestPerfProfiler.test_python_calls_do_not_appear_in_the_stack_if_perf_deactivated) ... skipped 'Unwinding is unreliable with frame pointers' test_python_calls_appear_in_the_stack_if_perf_activated (test.test_perf_profiler.TestPerfProfilerWithDwarf.test_python_calls_appear_in_the_stack_if_perf_activated) ... perf record -g --call-graph=dwarf,65528 -F99 -k1 -o /tmp/tmp52ljdy43/perf_output.perf -- /home/user/work/ce-sw/repos/cpython/build/python -Xperf_jit /tmp/tmp52ljdy43/perftest.py FAIL test_python_calls_do_not_appear_in_the_stack_if_perf_deactivated (test.test_perf_profiler.TestPerfProfilerWithDwarf.test_python_calls_do_not_appear_in_the_stack_if_perf_deactivated) ... perf record -g --call-graph=dwarf,65528 -F99 -k1 -o /tmp/tmpj41x5k9d/perf_output.perf -- /home/user/work/ce-sw/repos/cpython/build/python /tmp/tmpj41x5k9d/perftest.py ok test_sys_api (test.test_perf_profiler.TestPerfTrampoline.test_sys_api) ... ok test_sys_api_get_status (test.test_perf_profiler.TestPerfTrampoline.test_sys_api_get_status) ... ok test_sys_api_with_existing_trampoline (test.test_perf_profiler.TestPerfTrampoline.test_sys_api_with_existing_trampoline) ... ok test_sys_api_with_invalid_trampoline (test.test_perf_profiler.TestPerfTrampoline.test_sys_api_with_invalid_trampoline) ... ok test_trampoline_works (test.test_perf_profiler.TestPerfTrampoline.test_trampoline_works) ... ok test_trampoline_works_with_forks (test.test_perf_profiler.TestPerfTrampoline.test_trampoline_works_with_forks) ... ok ====================================================================== FAIL: test_python_calls_appear_in_the_stack_if_perf_activated (test.test_perf_profiler.TestPerfProfilerWithDwarf.test_python_calls_appear_in_the_stack_if_perf_activated) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/user/work/ce-sw/repos/cpython/Lib/test/test_perf_profiler.py", line 357, in test_python_calls_appear_in_the_stack_if_perf_activated self.assertIn(f"py::bar:{script}", stdout) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: 'py::bar:/tmp/tmp52ljdy43/perftest.py' not found in 'python 1359175 378278.191585: 10101010 task-clock:ppp: \n\t b5794db789fc _PyInterpreterState_GET+0x8 (inlined)\n\t b5794db789fc get_state+0x8 (inlined)\n\t b5794db789fc _PyObject_Malloc+0x8 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794db2c383 _PyLong_FromMedium+0xff (inlined)\n\t b5794db2c383 PyLong_FromLong+0xff (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8e087 _PyEval_EvalFrameDefault+0xa4f7 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.201687: 10101010 task-clock:ppp: \n\t b5794db250f0 x_add+0x20 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8800f _PyEval_EvalFrameDefault+0x447f (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.211789: 10101010 task-clock:ppp: \n\t b5794db789fc _PyInterpreterState_GET+0x8 (inlined)\n\t b5794db789fc get_state+0x8 (inlined)\n\t b5794db789fc _PyObject_Malloc+0x8 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794db25143 _PyLong_New+0x73 (inlined)\n\t b5794db25143 x_add+0x73 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8800f _PyEval_EvalFrameDefault+0x447f (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.221886: 10101010 task-clock:ppp: \n\t b5794db60eac _PyInterpreterState_GET+0xc (inlined)\n\t b5794db60eac get_state+0xc (inlined)\n\t b5794db60eac _PyObject_Free+0xc (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794db60eac _PyObject_Free+0xc (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da88257 _PyEval_EvalFrameDefault+0x46c7 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.231989: 10101010 task-clock:ppp: \n\t b5794db25218 long_normalize+0x148 (inlined)\n\t b5794db25218 x_add+0x148 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8800f _PyEval_EvalFrameDefault+0x447f (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.242093: 10101010 task-clock:ppp: \n\t b5794da88034 _PyEval_EvalFrameDefault+0x44a4 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.252194: 10101010 task-clock:ppp: \n\t b5794da88020 _PyEval_EvalFrameDefault+0x4490 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.262291: 10101010 task-clock:ppp: \n\t b5794da88250 _PyEval_EvalFrameDefault+0x46c0 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.272398: 10101010 task-clock:ppp: \n\t b5794da8822c _PyEval_EvalFrameDefault+0x469c (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.282497: 10101010 task-clock:ppp: \n\t b5794db78ac4 pymalloc_pool_extend+0xd0 (inlined)\n\t b5794db78ac4 pymalloc_alloc+0xd0 (inlined)\n\t b5794db78ac4 _PyObject_Malloc+0xd0 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794db2c383 _PyLong_FromMedium+0xff (inlined)\n\t b5794db2c383 PyLong_FromLong+0xff (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8e087 _PyEval_EvalFrameDefault+0xa4f7 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.292598: 10101010 task-clock:ppp: \n\t b5794db250f0 x_add+0x20 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8800f _PyEval_EvalFrameDefault+0x447f (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.302700: 10101010 task-clock:ppp: \n\t b5794db60eac _PyInterpreterState_GET+0xc (inlined)\n\t b5794db60eac get_state+0xc (inlined)\n\t b5794db60eac _PyObject_Free+0xc (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794db60eac _PyObject_Free+0xc (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da88257 _PyEval_EvalFrameDefault+0x46c7 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.312798: 10101010 task-clock:ppp: \n\t b5794db250f0 x_add+0x20 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8800f _PyEval_EvalFrameDefault+0x447f (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.322900: 10101010 task-clock:ppp: \n\t b5794db25124 _PyLong_New+0x54 (inlined)\n\t b5794db25124 x_add+0x54 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8800f _PyEval_EvalFrameDefault+0x447f (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.333001: 10101010 task-clock:ppp: \n\t b5794da8a200 _PyEval_EvalFrameDefault+0x6670 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.343099: 10101010 task-clock:ppp: \n\t b5794da89784 Py_INCREF+0x5bf4 (inlined)\n\t b5794da89784 _Py_NewRef+0x5bf4 (inlined)\n\t b5794da89784 _PyEval_EvalFrameDefault+0x5bf4 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.353200: 10101010 task-clock:ppp: \n\t b5794db25214 long_normalize+0x144 (inlined)\n\t b5794db25214 x_add+0x144 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8800f _PyEval_EvalFrameDefault+0x447f (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.363305: 10101010 task-clock:ppp: \n\t b5794da89784 Py_INCREF+0x5bf4 (inlined)\n\t b5794da89784 _Py_NewRef+0x5bf4 (inlined)\n\t b5794da89784 _PyEval_EvalFrameDefault+0x5bf4 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.373421: 10101010 task-clock:ppp: \n\t b5794db2c3d4 PyLong_FromLong+0x150 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8e087 _PyEval_EvalFrameDefault+0xa4f7 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.383504: 10101010 task-clock:ppp: \n\t b5794db251b8 x_add+0xe8 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8800f _PyEval_EvalFrameDefault+0x447f (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.393612: 10101010 task-clock:ppp: \n\t b5794da897b0 _PyEval_EvalFrameDefault+0x5c20 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.403708: 10101010 task-clock:ppp: \n\t b5794db60eac _PyInterpreterState_GET+0xc (inlined)\n\t b5794db60eac get_state+0xc (inlined)\n\t b5794db60eac _PyObject_Free+0xc (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794db60eac _PyObject_Free+0xc (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da88257 _PyEval_EvalFrameDefault+0x46c7 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.413813: 10101010 task-clock:ppp: \n\t b5794db77c14 PyObject_Malloc+0x14 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794db25143 _PyLong_New+0x73 (inlined)\n\t b5794db25143 x_add+0x73 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8800f _PyEval_EvalFrameDefault+0x447f (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.423910: 10101010 task-clock:ppp: \n\t b5794db60f28 _PyObject_Free+0x88 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da88257 _PyEval_EvalFrameDefault+0x46c7 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.434011: 10101010 task-clock:ppp: \n\t b5794db251dc x_add+0x10c (/home/user/work/ce-sw/repos/cpython/build/python)\n\t b5794da8800f _PyEval_EvalFrameDefault+0x447f (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\npython 1359175 378278.444112: 10101010 task-clock:ppp: \n\t b5794da8e080 _PyEval_EvalFrameDefault+0xa4f0 (/home/user/work/ce-sw/repos/cpython/build/python)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\t e917a72f05cb py::foo:/tmp/tmp52ljdy43/perftest.py+0xb (/tmp/perf-1359175.map)\n\n' ---------------------------------------------------------------------- Ran 11 tests in 2.981s FAILED (failures=1, skipped=3) test test_perf_profiler failed test_perf_profiler failed (1 failure) == Tests result: FAILURE == 1 test failed: test_perf_profiler Total duration: 5.2 sec Total tests: run=11 failures=1 skipped=3 Total test files: run=1/1 failed=1 Result: FAILURE ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-124792 * gh-124793 * gh-124794 * gh-124797 * gh-124869 * gh-124870 <!-- /gh-linked-prs -->
35541c410d894d4fa18002f7fdbebfe522f8320e
fac5e7aa171f8547fcb56f090e718c15ffd79d0b
python/cpython
python__cpython-124626
# Replace container images to packages from cpython-devcontainers Now we can manage our own package images at https://github.com/python/cpython-devcontainers and publish them through https://github.com/orgs/python/packages, so it's time to use them. - [x] autoconf - [x] devcontainer cc @brettcannon @erlend-aasland <!-- gh-linked-prs --> ### Linked PRs * gh-124626 * gh-124657 * gh-125320 * gh-126183 * gh-126184 <!-- /gh-linked-prs -->
a4d1fdfb152c46e3e05aa6e91a44a9fd0323b632
7d3497f617edf77cb6ead6f5e62bce98d77b9ab8
python/cpython
python__cpython-124663
# _Py_ThreadId() fails when compiled using GCC on Windows # Bug report ### Bug description: It should be possible to build a C extension module using GCC on Windows, but when defining Py_GIL_DISABLED any call to _Py_ThreadId fails. The if/defs in _Py_ThreadId look for _MSC_VER to be defined to determine whether it's a Windows build or not, but that specifies the VS version and not whether the build is for Windows or not. Instead it would be better to use _WIN32 (see https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170) Something along these lines... ``` #if defined(_WIN32) #include <intrin.h> #endif static inline uintptr_t _Py_ThreadId(void) { uintptr_t tid; #if defined(_WIN32) && defined(_M_X64) tid = __readgsqword(48); #elif defined(_WIN32) && defined(_M_IX86) tid = __readfsdword(24); #elif defined(_WIN32) && defined(_M_ARM64) tid = __getReg(18); ... ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-124663 * gh-124698 <!-- /gh-linked-prs -->
0881e2d3b1212d988733f1d3acca4011ce5e6280
2e155536caf8a090c06d62dd92647abc62362463
python/cpython
python__cpython-124607
# Reference leak in `test_datetime` # Bug report ### Bug description: ```python ./python -m test -R 3:3 test_datetime Using random seed: 2162639794 0:00:00 load avg: 88.54 Run 1 test sequentially in a single process 0:00:00 load avg: 88.54 [1/1] test_datetime beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more) 123:456 XXX 999 test_datetime leaked [9, 9, 9] references, sum=27 test_datetime leaked [3, 3, 3] memory blocks, sum=9 test_datetime failed (reference leak) == Tests result: FAILURE == 1 test failed: test_datetime Total duration: 21.9 sec Total tests: run=1,026 skipped=31 Total test files: run=1/1 failed=1 Result: FAILURE ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-124607 <!-- /gh-linked-prs -->
9c98fdab7d1167211c9d162c418e2b443a02867a
257a20a81764fcc17bcde9c0cec57fbc53a4adc7
python/cpython
python__cpython-124595
# Every input in asyncio REPL (wrongly) runs in a separate PEP 567 context # Bug report ### Bug description: The bug is twofold, affects the asyncio REPL, and refers to [PEP 567 contexts](https://peps.python.org/pep-0567/#contextvars-context) and [context variables](https://peps.python.org/pep-0567/#contextvars-contextvar). 1. Non-async inputs don't run in the same context. <details> This is how we can use the standard Python REPL to demonstrate context variables (without asyncio tasks): ``` Python 3.14.0a0 (heads/main-dirty:8447c933da3, Sep 25 2024, 15:45:56) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import contextvars >>> var = contextvars.ContextVar("var") >>> var.set("ok") <Token var=<ContextVar name='var' at ...> at ...> >>> var.get() 'ok' ``` I'd expect the asyncio REPL to be a slightly better tool for presenting them though. However, I ran into a problem with running the same sequence of instructions in that REPL, because it implicitly copies the context for every input and then runs the instructions in that copied context: ``` asyncio REPL 3.14.0a0 (heads/main-dirty:8447c933da3, Sep 25 2024, 15:45:56) [GCC 11.4.0] on linux Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. >>> import asyncio >>> import contextvars >>> var = contextvars.ContextVar("var") >>> var.set("ok") <Token var=<ContextVar name='var' at ...> at ...> >>> var.get() Traceback (most recent call last): File ".../cpython/Lib/concurrent/futures/_base.py", line 448, in result return self.__get_result() ~~~~~~~~~~~~~~~~~^^ File ".../cpython/Lib/concurrent/futures/_base.py", line 393, in __get_result raise self._exception File ".../cpython/Lib/asyncio/__main__.py", line 40, in callback coro = func() File "<python-input-3>", line 1, in <module> var.get() ~~~~~~~^^ LookupError: <ContextVar name='var' at ...> ``` </details> I assume it to just be a leftover of before [the `context` parameter for asyncio routines became a thing in 3.11](https://github.com/python/cpython/issues/91150). 3. Async inputs don't run in the same context. Similar to the first part, but this applies to every coroutine being run in the REPL. <details> By standard, a simple coroutine _does not_ run in a separate context (in contrast to [tasks](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task) that document their handling of context). Consider the following script: ```py import asyncio from contextvars import ContextVar var = ContextVar("var", default="unset") async def setvar() -> None: var.set("set") async def main() -> None: await setvar() # runs in *this* context print(var.get()) # gets us "set", not "unset" asyncio.run(main()) print(var.get()) # coro passed to asyncio.run() runs in a copied context, which gets us "unset" here ``` In the REPL, I'd expect that we're inside the "global" context of `asyncio.run()`—what I mean by this is that the context we work in (for the entire REPL session) is the same one that is reused to run every asynchronous input, because we're in the same "main" task, and the point of asyncio REPL is to be able to omit it. While it is expected that every asynchronous input with top-level `await` statements becomes a task for the current event loop internally, I would imagine that the behavior resembles what I'd get by merging all the inputs together and putting them inside a `async def main()` function in a Python script. For that reason, I consider the following a part of the bug: ``` asyncio REPL 3.14.0a0 (heads/main-dirty:8447c933da3, Sep 25 2024, 15:45:56) [GCC 11.4.0] on linux Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. >>> import asyncio >>> import contextvars >>> var = contextvars.ContextVar("var") >>> async def setvar(): ... var.set("ok") ... >>> await setvar() >>> var.get() Traceback (most recent call last): File ".../cpython/Lib/concurrent/futures/_base.py", line 448, in result return self.__get_result() ~~~~~~~~~~~~~~~~~^^ File ".../cpython/Lib/concurrent/futures/_base.py", line 393, in __get_result raise self._exception File ".../cpython/Lib/asyncio/__main__.py", line 40, in callback coro = func() File "<python-input-4>", line 1, in <module> var.get() ~~~~~~~^^ LookupError: <ContextVar name='var' at ...> ``` I'd expect every asynchronous input to not run in an implicitly copied context, because that's what feels like if we were writing a huge `async def main()` function—every `await` does not create a task, it just awaits the coroutine (the execution of which is managed by the event loop). Instead of comparing to a huge `async def main()`, I could say that we're reusing the same event loop over and over, and that can theoretically mean we want one global context only, not a separate one every time. </details> Interestingly, [IPython](https://github.com/ipython/ipython?tab=readme-ov-file#ipython-productive-interactive-computing) (which works asynchronously under the hood too) only runs into part 2. Thanks to the already mentioned GH-91150, this is very simple to manage and fix. Expect a PR soon. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-124595 * gh-124848 * gh-124849 <!-- /gh-linked-prs -->
67e01a430f4ecfcb540d6a29b347966ff4e53454
3e3a4d231518f91ff2f3c5a085b3849e32f1d548
python/cpython
python__cpython-124976
# ctypes.Union & ctypes.Structure: common features should be tested on both types Currently, `Lib/test/test_ctypes/test_structure.py` is very long, but `Lib/test/test_ctypes/test_union.py` only has recent additions. A lot of the Structure tests apply to Union as well, and should be run on both. My plan is: - Move tests of common features to `Lib/test/test_ctypes/test_structunion.py`, and use the “common base class + two subclasses” pattern used for tests of similar classes - Keep the Structure-specific tests in `Lib/test/test_ctypes/test_structure.py` <!-- gh-linked-prs --> ### Linked PRs * gh-124976 <!-- /gh-linked-prs -->
01fc3b34cc6994bc83b6540da3a8573e79dfbb56
c914212474792312bb125211bae5719650fe2f58
python/cpython
python__cpython-124553
# Improve the accuracy of possible breakpoint check in bdb # Feature or enhancement ### Proposal: Currently in `bdb`, when a new function is entered, `bdb` checks if it's possible that there's a breakpoint in that function and only enable events in that function if there is. It's a good strategy but the existing check is too loose. It equivalently check if there is a breakpoint in the file that function is defined in. We have much better tools to determine whether the function has a breakpoint in it now. Without enabling unnecessary events in those functions, pdb would be much faster. ### 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-124553 <!-- /gh-linked-prs -->
adfe7657a3f1ce5d8384694ed27a40376a18fa6c
2d8b6a4e9d9a74e3c5270eec62716710ac197063
python/cpython
python__cpython-124627
# Crash when detaching dict from inline values and no memory is available # Bug report ### Bug description: Add to `test_class.py` in `TestInlineValues`: ```python def test_detach_materialized_dict_no_memory(self): a = WithAttrs() d = a.__dict__ _testcapi.set_nomemory(0) del a print(d["a"]) ``` This will crash because the dictionary will no longer points to valid memory: ``` #0 Py_XINCREF (op=<unknown at remote 0xdddddddddddddddd>) at ./Include/refcount.h:456 #1 _Py_XNewRef (obj=<unknown at remote 0xdddddddddddddddd>) at ./Include/refcount.h:488 #2 _Py_dict_lookup_threadsafe (mp=mp@entry=0x7ffff778ff50, key=key@entry='a', hash=<optimized out>, value_addr=value_addr@entry=0x7fffffffb078) at Objects/dictobject.c:1544 #3 0x0000000000518457 in dict_subscript (self={'b': <unknown at remote 0xdddddddddddddddd>, 'd': <unknown at remote 0xdddddddddddddddd>, 'a': <unknown at remote 0xdddddddddddddddd>, 'c': <unknown at remote 0xdddddddddddddddd>}, key='a') at Objects/dictobject.c:3325 #4 0x000000000049d8c6 in PyObject_GetItem (o=o@entry={'b': <unknown at remote 0xdddddddddddddddd>, 'd': <unknown at remote 0xdddddddddddddddd>, 'a': <unknown at remote 0xdddddddddddddddd>, 'c': <unknown at remote 0xdddddddddddddddd>}, key=key@entry='a') at Objects/abstract.c:158 ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-124627 * gh-124714 <!-- /gh-linked-prs -->
0e21cc6cf820679439d72e3ebd06227ee2a085f9
2357d5ba48cd9685cb36bcf92a0eaed86a85f4de
python/cpython
python__cpython-124559
# v3.13.0rc2 Segmentation Fault in gc.get_referents. PyCapsule->traverse_func is NULL # Crash report ### What happened? Hello! Thank you for all your work on CPython. Hopefully this crash report is helpful. While working on https://github.com/matplotlib/matplotlib/pull/28861, we noticed that our tests were segfaulting, and only on python3.13. Here is a minimal reproduction of that crash. I've also run it with python3.13-dbg and `-X dev` to hopefully provide more details. **Error Message** ``` python: ../Objects/capsule.c:321: capsule_traverse: Assertion `capsule->traverse_func != NULL' failed. ``` **Minimal Reproducible Example:** ```console $ python3.13 -m venv venv_313 $ source venv_313/bin/activate $ pip install matplotlib==3.9.2 $ python -X dev test.py ``` **test.py** ```python import gc from collections import deque from matplotlib.figure import Figure from matplotlib.lines import Line2D from matplotlib.collections import PathCollection def get_children(parent): if parent.__class__.__qualname__ == "PyCapsule": print(f"About to call gc.get_referents on {repr(parent)}") children = gc.get_referents(parent) # gc.get_referrers does not segfault, but gc.get_referents does if parent.__class__.__qualname__ == "PyCapsule": print(f"There are {len(children)} children") return children def breadth_first_search(start): to_visit = deque([start]) explored = set() try: gc.disable() # Can repro without this, but it should make behavior more consistent while len(to_visit) > 0: parent = to_visit.popleft() for child in get_children(parent): if id(child) in explored: continue explored.add(id(child)) to_visit.append(child) finally: gc.enable() def find_reference_cycles(): fig = Figure() ax = fig.add_subplot() ax.plot([1]) fig.clear() breadth_first_search(fig) if __name__ == "__main__": find_reference_cycles() ``` with python3.13 on Ubuntu 22.04.4 ```console $ python -VV Python 3.13.0rc2 (main, Sep 9 2024, 22:55:42) [GCC 11.4.0] $ python -X dev test.py About to call gc.get_referents on <capsule object "pybind11_function_record_capsule" at 0x7f79954f34d0> Fatal Python error: Segmentation fault Current thread 0x00007f79e687f280 (most recent call first): File "/home/justin/tmp/matplotlib_py313_segfault/test.py", line 10 in get_children File "/home/justin/tmp/matplotlib_py313_segfault/test.py", line 22 in breadth_first_search File "/home/justin/tmp/matplotlib_py313_segfault/test.py", line 35 in find_reference_cycles File "/home/justin/tmp/matplotlib_py313_segfault/test.py", line 38 in <module> Extension modules: numpy._core._multiarray_umath, numpy.linalg._umath_linalg, PIL._imaging, kiwisolver._cext (total: 4) Segmentation fault (core dumped) ``` with python3.13-dbg on Ubuntu 22.04.4: ```console $ python -VV Python 3.13.0rc2 (main, Sep 9 2024, 22:55:42) [GCC 11.4.0] $ python -X dev test.py About to call gc.get_referents on <capsule object "pybind11_function_record_capsule" at 0x7f0c31adba80> python: ../Objects/capsule.c:321: capsule_traverse: Assertion `capsule->traverse_func != NULL' failed. Fatal Python error: Aborted Current thread 0x00007f0c82d1a280 (most recent call first): File "/home/justin/tmp/matplotlib_py313_segfault/test.py", line 10 in get_children File "/home/justin/tmp/matplotlib_py313_segfault/test.py", line 22 in breadth_first_search File "/home/justin/tmp/matplotlib_py313_segfault/test.py", line 35 in find_reference_cycles File "/home/justin/tmp/matplotlib_py313_segfault/test.py", line 38 in <module> Extension modules: numpy._core._multiarray_umath, numpy.linalg._umath_linalg, PIL._imaging, kiwisolver._cext (total: 4) Aborted (core dumped) ``` It does not crash with python3.12 on Ubuntu 22.04.4 ```console $ python -VV Python 3.12.6 (main, Sep 10 2024, 00:05:17) [GCC 11.4.0] $ python -X dev test.py About to call gc.get_referents on <capsule object "pybind11_function_record_capsule" at 0x7f85a852a570> There are 0 children [ ... many similar log lines removed ... ] ``` Side-note: I tested this on both python3.12 and 3.13, but not the main branch. The Github Issue dropdown doesn't have a 3.13rc2 option for me to check. ### CPython versions tested on: 3.12 ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.13.0rc2 (main, Sep 9 2024, 22:55:42) [GCC 11.4.0] <!-- gh-linked-prs --> ### Linked PRs * gh-124559 * gh-124588 <!-- /gh-linked-prs -->
f923605658a29ff9af5a62edc1fc10191977627b
0387c34f7c91428681ca8a4ba4e3d22b9acffde4
python/cpython
python__cpython-124546
# Breaking backward compatibility between `ctypes` and metaclasses in Python 3.13. # Documentation ## Background I am one of the maintainers of [`comtypes`](https://github.com/enthought/comtypes/). `comtypes` is based on `ctypes` and uses metaclasses to implement [`IUnknown`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nn-unknwn-iunknown). It was reported to the `comtypes` community that [an error occurs when attempting to use conventional metaclasses with Python 3.13](https://github.com/enthought/comtypes/issues/618#issuecomment-2366905288). A similar error was encountered in [`pyglet`](https://github.com/pyglet/pyglet), which also uses metaclasses to implement COM interfaces, when running on Python 3.13. By referring to https://github.com/pyglet/pyglet/issues/1196 and https://github.com/pyglet/pyglet/pull/1199, I made several modifications to the code through trial and error, and now `comtypes` works in both Python 3.13 and earlier versions without problems: - https://github.com/enthought/comtypes/compare/a3a8733..04b766a - It is necessary to pass arguments directly to the metaclass instead of using `__new__` in places where the metaclass is instantiated (i.e., where the class is dynamically defined). This also works in versions prior to Python 3.13. - After calling `type.__new__`, any remaining initialization would be handled in `__init__` instead of in `__new__`. Since this results in an error in versions prior to Python 3.13, a bridge using `sys.version_info` is necessary. I think these changes are likely related to https://github.com/python/cpython/issues/114314 and https://github.com/python/cpython/issues/117142 and were introduced by the PRs linked to those issues. Since this change to `ctypes` breaks compatibility, I think it should be mentioned in the [What’s New In Python 3.13](https://docs.python.org/3.13/whatsnew/3.13.html) and/or in the [`ctypes` documentation](https://docs.python.org/3.13/library/ctypes.html). There are likely other projects besides `comtypes` and `pyglet` that rely on the combination of `ctypes` and metaclasses, and I want to prevent confusion for those maintainers when they try to support Python 3.13. (Additionally, I would like to ask with the `ctypes` maintainers to confirm whether the changes for the metaclasses in `comtypes` (and `pyglet`) are appropriate.) <!-- gh-linked-prs --> ### Linked PRs * gh-124546 * gh-124708 <!-- /gh-linked-prs -->
3387f76b8f0b9f5ef89f9526c583bcc3dc36f486
d8cf587dc749cf21eafc1064237970ee7460634f
python/cpython
python__cpython-124515
# framelocalsproxy_new() crash if called with no arguments # Bug report Example on Python 3.13.0rc2: ``` $ python3.13 >>> import sys >>> FrameLocalsProxy=type([sys._getframe().f_locals for x in range(1)][0]) ... >>> FrameLocalsProxy() Erreur de segmentation (core dumped) ``` The bug was discovered by zope.interface test suite: https://github.com/zopefoundation/zope.interface/issues/323#issuecomment-2373346327 I'm working on a fix. <!-- gh-linked-prs --> ### Linked PRs * gh-124515 * gh-124539 <!-- /gh-linked-prs -->
d6954b6421aa34afd280df9c44ded21a2348a6ea
0d9d56c4e4246495f506f7fb319548fb105b535b
python/cpython
python__cpython-137010
# Stack-based `ast.literal_eval` Implementation # Feature or enhancement ### Proposal I have implemented a stack-based version of `ast.literal_eval` and conducted benchmarks to compare its performance with the existing implementation. The results indicate that the stack-based version may improve performance on non-nested expressions, although it is slightly slower on nested expressions. ### Benchmark Results The benchmarks were conducted on an Intel(R) Core(TM) Ultra 9 185H. Below are the results comparing `ast.literal_eval` and `stack_literal_eval`: ![benchmark](https://github.com/user-attachments/assets/a38f7d1c-bc76-4b11-b0c4-a259a1eeb092) ### Question I wonder if this change is desirable? ### Code See [here](https://github.com/Stanley5249/stack-literal-eval). ### Related Issue This work is related to the closed issue #75934. --- ### 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-137010 <!-- /gh-linked-prs -->
b723c8be071afcf3f865c55a5efb6da54f7695a0
d5191ba99b8f7723cbdb9b7a07ef8a3eef6524c1
python/cpython
python__cpython-124504
# [C API] Add PyUnicode_Equal() function Python 3.13 moved the private _PyUnicode_EQ() function to internal C API. [mypy](https://github.com/python/cpython/issues/121489) and [Pyodide](https://github.com/capi-workgroup/problems/issues/79) are using it. I propose to add a public PyUnicode_Equal(a, b) function to the limited C API 3.14 to replace the private _PyUnicode_EQ() function: * Return `1` if *a* is equal to *b*. * Return `0` if *a* is not equal to *b*. * Set a `TypeError` exception and return `-1` if *a* or *b* is not a Python `str` object. * The function always succeed if *a* and *b* are strings. <!-- gh-linked-prs --> ### Linked PRs * gh-124504 * gh-125070 * gh-125105 * gh-125114 <!-- /gh-linked-prs -->
a7f0727ca575fef4d8891b5ebfe71ef2a774868b
c5df1cb7bde7e86f046196b0e34a0b90f8fc11de
python/cpython
python__cpython-124499
# TypeAliasType is always generic when `type_params=()` is passed. # Bug report ### Bug description: I realized that the `type_params` parameter of `TypeAliasType` behaves differently when it is omitted vs passing an empty tuple `()`, in the latter case the resulting instance is always subscriptable. I doubt this is an undocumented feature. ```python from typing import List, TypeAliasType, TypeVar # < Errors like expected > Simple = TypeAliasType("Simple", int) try: Simple[int] except TypeError: print("Expected: Simple is not subcriptable") # Not allowed assignment T = TypeVar('T') MissingTypeParamsErr = TypeAliasType("MissingTypeParamsErr", List[T]) assert MissingTypeParamsErr.__type_params__ == () assert MissingTypeParamsErr.__parameters__ == () try: MissingTypeParamsErr[int] except TypeError: print("Expected: Simple is not subcriptable") # < unexpected cases > MissingTypeParams = TypeAliasType("MissingTypeParams", List[T], type_params=()) assert MissingTypeParams.__type_params__ == () assert MissingTypeParams.__parameters__ == () # These cases do not raise an error MissingTypeParams[int] MissingTypeParams[[]] MissingTypeParams[()] # This also do not raise an error Simple2 = TypeAliasType("Simple2", int, type_params=()) assert Simple2 .__type_params__ == () assert Simple2 .__parameters__ == () Simple2[int] Simple2[[]] Simple2[()] ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-124499 * gh-124603 * gh-124604 <!-- /gh-linked-prs -->
abe5f799e6ce1d177f79554f1b84d348b6141045
cf2418076d7cf69a3bd4bf6be0e0001635a7ad4d
python/cpython
python__cpython-124672
# Python-3.13.0rc2 cannot build in windows 11 with visual studio 2022 and windows sdk 10.0.26100 # Bug report ### Bug description: same as [Error when building _freeze_module](https://github.com/python/cpython/issues/121629) in C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um\ProcessSnapshot.h#L370 ``` #if (NTDDI_VERSION >= NTDDI_WINBLUE) // Win32 APIs. _Success_(return == ERROR_SUCCESS) STDAPI_(DWORD) PssCaptureSnapshot( _In_ HANDLE ProcessHandle, _In_ PSS_CAPTURE_FLAGS CaptureFlags, _In_opt_ DWORD ThreadContextFlags, _Out_ HPSS* SnapshotHandle ); ``` but in pyconfig.h#L165 ``` #define Py_WINVER 0x0602 /* _WIN32_WINNT_WIN8 */ #define Py_NTDDI NTDDI_WIN8 ``` in Msi.h#L45 ``` #ifndef NTDDI_WIN8 #define NTDDI_WIN8 0x06020000 #endif #ifndef NTDDI_WINBLUE #define NTDDI_WINBLUE 0x06030000 #endif ``` May be that is the problem, with NTDDI not large enough, the PssCaptureSnapshot is not defined, then build failed. below is full log ``` E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild>build.bat -p x64 -c Release -t Build -v --disable-gil Using "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\\..\externals\pythonx86\tools\python.exe" (found in externals directory) Fetching external libraries... bzip2-1.0.8 already exists, skipping. mpdecimal-4.0.0 already exists, skipping. sqlite-3.45.3.0 already exists, skipping. xz-5.2.5 already exists, skipping. zlib-1.3.1 already exists, skipping. Fetching external binaries... libffi-3.4.4 already exists, skipping. openssl-bin-3.0.15 already exists, skipping. tcltk-8.6.14.0 already exists, skipping. Finished. Using "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe" (found in the PATH) Using "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\\..\externals\pythonx86\tools\python.exe" (found in externals directory) E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild>"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\pcbuild.proj" /t:Build /m /v:n /p:Configuration=Release /p:Platform=x64 /p:IncludeExternals=true /p:IncludeCTypes=true /p:IncludeSSL=true /p:IncludeTkinter=true /p:DisableGil=true /p:UseTestMarker= /p:GIT="C:\Program Files\Git\cmd\git.exe" /p:UseJIT= /p:UseTIER2= 适用于 .NET Framework MSBuild 版本 17.11.9+a69bbaaf5 生成启动时间为 2024-09-25 10:18:45。 1>项目“E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\pcbuild.proj”在节点 1 上(Build 个目标)。 1>项目“E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\pcbuild.proj”(1)正在节点 1 上生成“E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj”(2) (Build 个目标)。 2>PrepareForBuild: 已启用结构化输出。编译器诊断的格式设置将反映错误层次结构。有关详细信息,请参阅 https://aka.ms/cpp/structured-output。 InitializeBuildStatus: 正在对“E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\_freeze_module.tlog\unsuccessfulbuild”执行 Touch 任务。 VcpkgTripletSelection: Using triplet "x86-windows" from "C:\Users\joshu\Codes\vcpkg\installed\x86-windows\" Using normalized configuration "Release" ClCompile: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX86\x86\CL.exe /c /I"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\\ " /I"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Include" /I"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Include\internal" /I"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Include\internal\mimalloc" /I"E: \Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\\313win32_Release\pythoncore\\" /I"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PC" /I"C:\Users\joshu\Codes\vcpkg\installed\x86-windows\include" /Zi /nologo /W3 /WX- /diagnostics:column /MP /Od /Oi /Oy- /D Py_NO_ENABLE_SHARED /D Py_BUILD_CORE /D _CONSOLE /D WIN32 /D "PY3_DLLNAME=L\"python3t\"" /D _WIN32 /D NDEBUG /D _UNICODE /D UNICODE /GF /Gm- /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\\" /Fd"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc 2\PCbuild\obj\313win32_Release\_freeze_module\vc143.pdb" /external:W3 /Gd /TC /analyze- /FC /errorReport:queue /utf-8 ..\Programs\_freeze_module.c ..\PC\config_minimal.c ..\Modules\atexitmodule.c ..\ Modules\faulthandler.c ..\Modules\gcmodule.c ..\Modules\getbuildinfo.c ..\Modules\getpath_noop.c ..\Modules\posixmodule.c ..\Modules\signalmodule.c ..\Modules\timemodule.c ..\Modules\_tracemalloc.c . .\Modules\_io\_iomodule.c ..\Modules\_io\bufferedio.c ..\Modules\_io\bytesio.c ..\Modules\_io\fileio.c ..\Modules\_io\iobase.c ..\Modules\_io\stringio.c ..\Modules\_io\textio.c ..\Modules\_io\wincons oleio.c ..\Objects\abstract.c ..\Objects\boolobject.c ..\Objects\bytearrayobject.c ..\Objects\bytes_methods.c ..\Objects\bytesobject.c ..\Objects\call.c ..\Objects\capsule.c ..\Objects\cellobject.c . .\Objects\classobject.c ..\Objects\codeobject.c ..\Objects\complexobject.c ..\Objects\descrobject.c ..\Objects\dictobject.c ..\Objects\enumobject.c ..\Objects\exceptions.c ..\Objects\fileobject.c ..\ Objects\floatobject.c ..\Objects\frameobject.c ..\Objects\funcobject.c ..\Objects\genericaliasobject.c ..\Objects\genobject.c ..\Objects\iterobject.c ..\Objects\listobject.c ..\Objects\longobject.c . .\Objects\memoryobject.c ..\Objects\methodobject.c ..\Objects\moduleobject.c ..\Objects\namespaceobject.c ..\Objects\object.c ..\Objects\obmalloc.c ..\Objects\odictobject.c ..\Objects\picklebufobject .c ..\Objects\rangeobject.c ..\Objects\setobject.c ..\Objects\sliceobject.c ..\Objects\structseq.c ..\Objects\tupleobject.c ..\Objects\typeobject.c ..\Objects\typevarobject.c ..\Objects\unicodectype. c ..\Objects\unicodeobject.c ..\Objects\unionobject.c ..\Objects\weakrefobject.c ..\Parser\myreadline.c ..\Parser\parser.c ..\Parser\peg_api.c ..\Parser\pegen.c ..\Parser\pegen_errors.c ..\Parser\act ion_helpers.c ..\Parser\string_parser.c ..\Parser\token.c ..\Parser\lexer\buffer.c ..\Parser\lexer\state.c ..\Parser\lexer\lexer.c ..\Parser\tokenizer\string_tokenizer.c ..\Parser\tokenizer\file_toke nizer.c ..\Parser\tokenizer\utf8_tokenizer.c ..\Parser\tokenizer\readline_tokenizer.c ..\Parser\tokenizer\helpers.c ..\PC\invalid_parameter_handler.c ..\PC\msvcrtmodule.c ..\PC\winreg.c ..\Python\_wa rnings.c ..\Python\asdl.c ..\Python\assemble.c ..\Python\ast.c ..\Python\ast_opt.c ..\Python\ast_unparse.c ..\Python\bltinmodule.c ..\Python\brc.c ..\Python\bootstrap_hash.c ..\Python\ceval.c ..\Pyth on\codecs.c ..\Python\compile.c ..\Python\context.c ..\Python\critical_section.c ..\Python\crossinterp.c ..\Python\dtoa.c ..\Python\dynamic_annotations.c ..\Python\dynload_win.c ..\Python\errors.c .. \Python\fileutils.c ..\Python\flowgraph.c ..\Python\formatter_unicode.c ..\Python\frame.c ..\Python\future.c ..\Python\gc.c ..\Python\gc_gil.c ..\Python\gc_free_threading.c ..\Python\getargs.c ..\Pyt hon\getcompiler.c ..\Python\getcopyright.c ..\Python\getopt.c ..\Python\getplatform.c ..\Python\getversion.c ..\Python\ceval_gil.c ..\Python\hamt.c ..\Python\hashtable.c ..\Python\import.c ..\Python\ importdl.c ..\Python\initconfig.c ..\Python\instruction_sequence.c ..\Python\interpconfig.c ..\Python\intrinsics.c ..\Python\instrumentation.c ..\Python\jit.c ..\Python\legacy_tracing.c ..\Python\loc k.c ..\Python\marshal.c ..\Python\modsupport.c ..\Python\mysnprintf.c ..\Python\mystrtoul.c ..\Python\object_stack.c ..\Python\optimizer.c ..\Python\optimizer_analysis.c ..\Python\optimizer_symbols.c ..\Python\parking_lot.c ..\Python\pathconfig.c ..\Python\perf_trampoline.c ..\Python\perf_jit_trampoline.c ..\Python\preconfig.c ..\Python\pyarena.c ..\Python\pyctype.c ..\Python\pyfpe.c ..\Python\p yhash.c ..\Python\pylifecycle.c ..\Python\pymath.c ..\Python\pystate.c ..\Python\pystrcmp.c ..\Python\pystrhex.c ..\Python\pystrtod.c "..\Python\Python-ast.c" ..\Python\pythonrun.c "..\Python\Python- tokenize.c" ..\Python\pytime.c ..\Python\qsbr.c ..\Python\specialize.c ..\Python\structmember.c ..\Python\suggestions.c ..\Python\symtable.c ..\Python\thread.c ..\Python\traceback.c ..\Python\tracema lloc.c _freeze_module.c config_minimal.c atexitmodule.c faulthandler.c gcmodule.c getbuildinfo.c getpath_noop.c posixmodule.c signalmodule.c timemodule.c _tracemalloc.c _iomodule.c bufferedio.c bytesio.c fileio.c 2>E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Modules\posixmodule.c(9366,13): warning C4013: “PssCaptureSnapshot”未定义;假设外部返回 int [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] 2>E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Modules\posixmodule.c(9372,13): warning C4013: “PssQuerySnapshot”未定义;假设外部返回 int [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] 2>E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Modules\posixmodule.c(9381,5): warning C4013: “PssFreeSnapshot”未定义;假设外部返回 int [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] iobase.c stringio.c textio.c winconsoleio.c abstract.c boolobject.c bytearrayobject.c bytes_methods.c bytesobject.c call.c capsule.c cellobject.c classobject.c codeobject.c complexobject.c descrobject.c dictobject.c enumobject.c exceptions.c fileobject.c floatobject.c frameobject.c funcobject.c genericaliasobject.c genobject.c iterobject.c listobject.c longobject.c memoryobject.c methodobject.c moduleobject.c namespaceobject.c object.c obmalloc.c odictobject.c picklebufobject.c rangeobject.c setobject.c sliceobject.c structseq.c tupleobject.c typeobject.c typevarobject.c unicodectype.c unicodeobject.c unionobject.c weakrefobject.c myreadline.c parser.c peg_api.c pegen.c pegen_errors.c action_helpers.c string_parser.c token.c buffer.c state.c lexer.c string_tokenizer.c file_tokenizer.c utf8_tokenizer.c readline_tokenizer.c helpers.c invalid_parameter_handler.c msvcrtmodule.c winreg.c _warnings.c asdl.c assemble.c ast.c ast_opt.c ast_unparse.c bltinmodule.c brc.c bootstrap_hash.c ceval.c codecs.c compile.c context.c critical_section.c crossinterp.c dtoa.c dynamic_annotations.c dynload_win.c errors.c fileutils.c flowgraph.c formatter_unicode.c frame.c future.c gc.c gc_gil.c gc_free_threading.c getargs.c getcompiler.c getcopyright.c getopt.c getplatform.c getversion.c ceval_gil.c hamt.c hashtable.c import.c importdl.c initconfig.c instruction_sequence.c interpconfig.c intrinsics.c instrumentation.c jit.c legacy_tracing.c lock.c marshal.c modsupport.c mysnprintf.c mystrtoul.c object_stack.c optimizer.c optimizer_analysis.c optimizer_symbols.c parking_lot.c pathconfig.c perf_trampoline.c perf_jit_trampoline.c preconfig.c pyarena.c pyctype.c pyfpe.c pyhash.c pylifecycle.c pymath.c pystate.c pystrcmp.c pystrhex.c pystrtod.c Python-ast.c pythonrun.c Python-tokenize.c pytime.c qsbr.c specialize.c structmember.c suggestions.c symtable.c thread.c traceback.c tracemalloc.c C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX86\x86\CL.exe /c /I"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\\ " /I"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Include" /I"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Include\internal" /I"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Include\internal\mimalloc" /I"E: \Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\\313win32_Release\pythoncore\\" /I"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PC" /I"C:\Users\joshu\Codes\vcpkg\installed\x86-windows\include" /Zi /nologo /W3 /WX- /diagnostics:column /MP /Od /Oi /Oy- /D "VPATH=\"..\\..\"" /D Py_NO_ENABLE_SHARED /D Py_BUILD_CORE /D _CONSOLE /D WIN32 /D "PY3_DLLNAME=L\"python3t\"" /D _WIN32 /D NDEBUG /D _UNICOD E /D UNICODE /GF /Gm- /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\\" /Fd"E:\Codes\Python-3.1 3.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\vc143.pdb" /external:W3 /Gd /TC /analyze- /FC /errorReport:queue /utf-8 ..\Python\sysmodule.c sysmodule.c Link: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX86\x86\link.exe /ERRORREPORT:QUEUE /OUT:"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\win32\_freeze_mo dule.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\win32\\" /LIBPATH:"C:\Users\joshu\Codes\vcpkg\installed\x86-windows\lib" /LIBPATH:"C:\Users\joshu\Codes\ vcpkg\installed\x86-windows\lib\manual-link" version.lib ws2_32.lib pathcch.lib bcrypt.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "C:\Users\joshu\Codes\vcpkg\installed\x86-windows\lib\*.lib" /NODEFAULTLIB:LIBC /MANIFEST:NO /DEBUG /PDB:"E:\Codes\Pyt hon-3.13.0rc2\Python-3.13.0rc2\PCbuild\win32\_freeze_module.pdb" /SUBSYSTEM:CONSOLE /LTCGOUT:"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\_freeze_module.iob j" /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\win32\_freeze_module.lib" /MACHINE:X86 /SAFESEH /OPT:REF,NOICF "E:\Codes\Python-3.13.0rc2\Python-3.13.0r c2\PCbuild\obj\313win32_Release\_freeze_module\_freeze_module.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\config_minimal.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\atexitmodule.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\faulthandler.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\gcmodule.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\getbuildinfo.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\getpath_noop.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\posixmodule.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\signalmodule.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\timemodule.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\_tracemalloc.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\_iomodule.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\bufferedio.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\bytesio.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\fileio.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\iobase.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\stringio.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\textio.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\winconsoleio.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\abstract.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\boolobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\bytearrayobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\bytes_methods.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\bytesobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\call.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\capsule.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\cellobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\classobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\codeobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\complexobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\descrobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\dictobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\enumobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\exceptions.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\fileobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\floatobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\frameobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\funcobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\genericaliasobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\genobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\iterobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\listobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\longobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\memoryobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\methodobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\moduleobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\namespaceobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\object.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\obmalloc.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\odictobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\picklebufobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\rangeobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\setobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\sliceobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\structseq.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\tupleobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\typeobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\typevarobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\unicodectype.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\unicodeobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\unionobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\weakrefobject.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\myreadline.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\parser.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\peg_api.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pegen.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pegen_errors.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\action_helpers.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\string_parser.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\token.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\buffer.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\state.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\lexer.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\string_tokenizer.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\file_tokenizer.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\utf8_tokenizer.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\readline_tokenizer.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\helpers.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\invalid_parameter_handler.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\msvcrtmodule.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\winreg.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\_warnings.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\asdl.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\assemble.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\ast.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\ast_opt.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\ast_unparse.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\bltinmodule.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\brc.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\bootstrap_hash.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\ceval.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\codecs.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\compile.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\context.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\critical_section.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\crossinterp.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\dtoa.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\dynamic_annotations.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\dynload_win.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\errors.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\fileutils.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\flowgraph.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\formatter_unicode.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\frame.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\future.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\gc.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\gc_gil.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\gc_free_threading.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\getargs.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\getcompiler.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\getcopyright.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\getopt.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\getplatform.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\getversion.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\ceval_gil.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\hamt.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\hashtable.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\import.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\importdl.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\initconfig.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\instruction_sequence.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\interpconfig.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\intrinsics.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\instrumentation.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\jit.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\legacy_tracing.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\lock.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\marshal.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\modsupport.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\mysnprintf.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\mystrtoul.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\object_stack.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\optimizer.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\optimizer_analysis.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\optimizer_symbols.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\parking_lot.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pathconfig.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\perf_trampoline.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\perf_jit_trampoline.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\preconfig.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pyarena.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pyctype.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pyfpe.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pyhash.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pylifecycle.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pymath.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pystate.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pystrcmp.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pystrhex.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pystrtod.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\Python-ast.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pythonrun.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\Python-tokenize.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\pytime.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\qsbr.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\specialize.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\structmember.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\suggestions.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\symtable.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\sysmodule.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\thread.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\traceback.obj" "E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\obj\313win32_Release\_freeze_module\tracemalloc.obj" 2>posixmodule.obj : error LNK2019: 无法解析的外部符号 _PssCaptureSnapshot,函数 _win32_getppid 中引用了该符号 [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] 2>posixmodule.obj : error LNK2019: 无法解析的外部符号 _PssQuerySnapshot,函数 _win32_getppid 中引用了该符号 [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] 2>posixmodule.obj : error LNK2019: 无法解析的外部符号 _PssFreeSnapshot,函数 _win32_getppid 中引用了该符号 [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] 2>E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\win32\_freeze_module.exe : fatal error LNK1120: 3 个无法解析的外部命令 [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] 2>已完成生成项目“E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj”(Build 个目标)的操作 - 失败。 1>已完成生成项目“E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\pcbuild.proj”(Build 个目标)的操作 - 失败。 生成失败。 “E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\pcbuild.proj”(Build 目标) (1) -> “E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj”(Build 目标) (2) -> (ClCompile 目标) -> E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Modules\posixmodule.c(9366,13): warning C4013: “PssCaptureSnapshot”未定义;假设外部返回 int [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj ] E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Modules\posixmodule.c(9372,13): warning C4013: “PssQuerySnapshot”未定义;假设外部返回 int [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\Modules\posixmodule.c(9381,5): warning C4013: “PssFreeSnapshot”未定义;假设外部返回 int [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] “E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\pcbuild.proj”(Build 目标) (1) -> “E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj”(Build 目标) (2) -> (Link 目标) -> posixmodule.obj : error LNK2019: 无法解析的外部符号 _PssCaptureSnapshot,函数 _win32_getppid 中引用了该符号 [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] posixmodule.obj : error LNK2019: 无法解析的外部符号 _PssQuerySnapshot,函数 _win32_getppid 中引用了该符号 [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] posixmodule.obj : error LNK2019: 无法解析的外部符号 _PssFreeSnapshot,函数 _win32_getppid 中引用了该符号 [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\win32\_freeze_module.exe : fatal error LNK1120: 3 个无法解析的外部命令 [E:\Codes\Python-3.13.0rc2\Python-3.13.0rc2\PCbuild\_freeze_module.vcxproj] 3 个警告 4 个错误 已用时间 00:00:26.57 ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-124672 * gh-124676 * gh-124702 * gh-124822 <!-- /gh-linked-prs -->
fac5e7aa171f8547fcb56f090e718c15ffd79d0b
077e7ef6a0abbf9e04b9aa11b4f621031004c31f
python/cpython
python__cpython-136335
# AssertionError in test_whichdb_ndbm on NetBSD # Bug report ### Bug description: ```python home$ ./python -m test test_dbm -m test_whichdb_ndbm Using random seed: 1067465967 0:00:00 load avg: 0.00 Run 1 test sequentially in a single process 0:00:00 load avg: 0.00 [1/1] test_dbm test test_dbm failed -- Traceback (most recent call last): File "/home/blue/cpython/Lib/test/test_dbm.py", line 221, in test_whichdb_ndbm self.assertIsNone(self.dbm.whichdb(path)) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: 'dbm.ndbm' is not None test_dbm failed (1 failure) == Tests result: FAILURE == 1 test failed: test_dbm Total duration: 285 ms Total tests: run=1 (filtered) failures=1 Total test files: run=1/1 (filtered) failed=1 Result: FAILURE ``` OS: `NetBSD 10.0 amd64` ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-136335 * gh-136378 * gh-136379 <!-- /gh-linked-prs -->
b7aa2a4b4df697db6ea45a555eeb3fefa5ca5bd4
73e1207a4ebdb3b43d597cd6c288dae6d7d1dbdb
python/cpython
python__cpython-124877
# Review and simplify argparse docs The argparse docs have become pretty lengthy. This is in part due to the examples, which are somewhat duplicative of the tutorial. I'd like to go through the docs to see if we can dedupe and pare things down to make them more readable. <!-- gh-linked-prs --> ### Linked PRs * gh-124877 * gh-125162 * gh-125164 <!-- /gh-linked-prs -->
37228bd16e3ef97d32da08848552f7ef016d68ab
eafd14fbe0fd464b9d700f6d00137415193aa143
python/cpython
python__cpython-124475
# Set name for reusable workflow ![Screenshot from 2024-09-24 13-54-42](https://github.com/user-attachments/assets/b6d882ad-b7d9-494c-9ae1-efb8c31da135) Visibility does not look good; let's set the name. cc @hugovk <!-- gh-linked-prs --> ### Linked PRs * gh-124475 * gh-125256 * gh-125257 <!-- /gh-linked-prs -->
e4cab488d4445e8444932f3bed1c329c0d9e5038
f9ae5d1cee2f8927a71cd4f1f66f10050a4f658a
python/cpython
python__cpython-122489
# Crash when assigning to instance dictionary from multiple threads while reading # Bug report ### Bug description: ```python class C: pass f = C() # Reader code: f.foo # Writer code: f.__dict__ = {} ``` When there's a thread reading from an object and another thread replacing the dictionary we can crash. This is because the read has a borrowed reference to the dictionary which gets simultaneously decref'd when the writer replaces it. Expected behavior: No crashes ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-122489 <!-- /gh-linked-prs -->
bf542f8bb9f12f0df9481f2222b21545806dd9e1
3926842117feffe5d2c9727e1899bea5ae2adb28
python/cpython
python__cpython-124460
# Drop `coverity` # Feature or enhancement ### Proposal: Drop references to `coverity`. The last time the project was scanned using coverity was 2020. Those listed as admins/experts on coverity hasn't been maintaining it. We discussed this during Python core sprint on Discord. A DevGuide PR was opened to also remove mention about coverity. ### Has this already been discussed elsewhere? I have already discussed this feature proposal on Discourse ### Links to previous discussion of this feature: https://github.com/python/devguide/pull/1411 <!-- gh-linked-prs --> ### Linked PRs * gh-124460 <!-- /gh-linked-prs -->
6cba6e1df2c20846347b705eff7fb28caeeb17fd
3387f76b8f0b9f5ef89f9526c583bcc3dc36f486
python/cpython
python__cpython-125919
# Parsing adds whitespace to the front of long headers # Bug report ### Bug description: When parsing back a written email, whitespace seems to be prepended to the header if the header was wrapped upon writing. This is particularly noticeable for message-ids, which end up different - with either a space or a newline prepended depending on what policy is set to (compat32: newline, default: space). ```python import string from email import message_from_bytes from email.message import EmailMessage import email.policy orig = EmailMessage() orig["Message-ID"] = string.ascii_lowercase * 3 policy = email.policy.default # changing to compat32 emits a different error parsed = message_from_bytes(orig.as_bytes(policy=policy), policy=policy) assert ( parsed["Message-ID"] == orig["Message-ID"] ), f"message ids don't match: '{orig['Message-ID']}' != '{parsed['Message-ID']}'" ``` I'm not very familiar with RFC2822, but based on the [rules it includes for "long" header fields](https://www.rfc-editor.org/rfc/rfc2822#section-2.2.3), the written email bytes look right to me, it's just when it's being read back it's not right. ### CPython versions tested on: 3.9, 3.12 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-125919 * gh-126916 * gh-126917 <!-- /gh-linked-prs -->
ed81971e6b26c34445f06850192b34458b029337
2313f8421080ceb3343c6f5d291279adea85e073
python/cpython
python__cpython-124449
# Update bundled Tcl/Tk to 8.6.15 (Windows, macOS installer) ### Proposal: 8.6.15 was released on Sep 13, 2024 ### 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-124449 * gh-124453 * gh-125795 * gh-125796 * gh-125800 * gh-125801 <!-- /gh-linked-prs -->
9d8f2d8e08336695fdade5846da4bbcc3eb5f152
909c6f718913e713c990d69e6d8a74c05f81e2c2
python/cpython
python__cpython-124492
# `__static_attributes__` is not deterministic # Bug report ### Bug description: Tested on commit: e9b00cc78853373623031c657193cbe557488c0a <!-- ZW: edited to remove markup for automatic GH link --> Order of strings in `__static_attributes__` is not deterministic Running the following a couple of times produces different hashes: ```bash /opt/cpython/cross-build/build/python ../../Programs/_freeze_module.py zipimport ../../Lib/zipimport.py Python/frozen_modules/zipimport.h sha256sum ./Python/frozen_modules/zipimport.h ``` I patched this generator to output dis as follows: ```diff diff --git a/Programs/_freeze_module.py b/Programs/_freeze_module.py index ba638ee..7e837e9 100644 --- a/Programs/_freeze_module.py +++ b/Programs/_freeze_module.py @@ -24,6 +24,9 @@ def compile_and_marshal(name: str, text: bytes) -> bytes: filename = f"<frozen {name}>" # exec == Py_file_input code = compile(text, filename, "exec", optimize=0, dont_inherit=True) + import dis + with open("/tmp/a", "at") as f: + dis.dis(code, file=f) return marshal.dumps(code) ``` Then disassembly differs in one place (after removing `at 0x[a-f0-9]*`): ```diff diff --git a/tmp/a b/tmp/b index 372a97c..4010046 100644 --- a/tmp/a +++ b/tmp/b @@ -291,7 +291,7 @@ Disassembly of <code object zipimporter , file "<frozen zipimport>", line 50>: 289 LOAD_CONST 15 (<code object __repr__ , file "<frozen zipimport>", line 289>) MAKE_FUNCTION STORE_NAME 16 (__repr__) - LOAD_CONST 16 (('archive', 'prefix')) + LOAD_CONST 16 (('prefix', 'archive')) STORE_NAME 17 (__static_attributes__) RETURN_CONST 4 (None) ``` diff in `.h` files is quite small, so I assume only sorting is affected: ```diff - 0,0,0,41,2,114,46,0,0,0,114,44,0,0,0,169, + 0,0,0,41,2,114,44,0,0,0,114,46,0,0,0,169, ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-124492 * gh-124738 <!-- /gh-linked-prs -->
04c837d9d8a474777ef9c1412fbba14f0682366c
69a4063ca516360b5eb96f5432ad9f9dfc32a72e
python/cpython
python__cpython-128669
# `asyncio.Queue.task_done` documentation is ambiguous # Documentation When reading https://docs.python.org/3/library/asyncio-queue.html the reader gets no clue to the fact that this object is (primarily) meant to contain tasks. (Because it is, isn't it? The task_done() method seems to indicate that) <!-- gh-linked-prs --> ### Linked PRs * gh-128669 * gh-128671 * gh-128672 <!-- /gh-linked-prs -->
4322a318ea98ceeb95d88b7ae6b5cfa3572d2069
b2adf556747d080f04b53ba4063b627c2dbe41d1
python/cpython
python__cpython-124551
# How to convert annotations to `Format.SOURCE` in `__annotate__`? # Feature or enhancement Let's say you have a dict of some custom annotations like I have in https://github.com/python/cpython/pull/122262 How users are expected to convert say an annotation dict of `{'user': CustomUser[AuthToken], 'auth_callback': Callable[[CustomUser[T]], T]}` to string? There are several ways right now: 1. `repr` for simple types, which might not work for complex ones 2. https://github.com/python/cpython/blob/536bc8a806008fff4880ad11ddc189e4847d0255/Lib/annotationlib.py#L466-L501 but, it requires complex `annotate` object 3. https://github.com/python/cpython/blob/536bc8a806008fff4880ad11ddc189e4847d0255/Lib/typing.py#L2955-L2956 but it is a private API I propose adding a public and documented API for that. <!-- gh-linked-prs --> ### Linked PRs * gh-124551 <!-- /gh-linked-prs -->
4e829c0e6fbd47818451660c234eacc42a0b4a08
0268b072d84bc4be890d1b7459815ba1cb9f9945
python/cpython
python__cpython-124466
# Skip additional tests for emulated Linux JIT CI jobs There have been a number of failed tests on emulated Linux JIT CI runs, related to`test_datetime` lately. We should add them to the list of skipped tests for now. See https://github.com/python/cpython/actions/runs/10942493409/job/30380093772?pr=124101 as an example. <!-- gh-linked-prs --> ### Linked PRs * gh-124466 <!-- /gh-linked-prs -->
b6471f4a391e9d3c8e1b244c56a4cc25974632c9
950fab46ad3a1960aa289d2d1de55447b88e25d7
python/cpython
python__cpython-124406
# NameError in `openpty` after #118826 # Bug report `result` jere is not defined https://github.com/python/cpython/blob/ad7c7785461fffba04f5a36cd6d062e92b0fda16/Lib/pty.py#L36-L43 It should be `slave_fd`. Caused by #118826 Thanks to @ambv for finding this. I have a fix ready. <!-- gh-linked-prs --> ### Linked PRs * gh-124406 <!-- /gh-linked-prs -->
17b3bc9cc7608920077f5f08f970c7157a2d2e72
b4d0d7de0f6d938128bf525e119c18af5632b804
python/cpython
python__cpython-124434
# test_free_threading and test_super take way to long on a Free Threaded build. # Bug report Running freshly updated and compiled main on my new machine, `python -m test -j0` (I forgot -ugui) ran all but 2 tests in 2:46. (16 cores defaulted to 2x16 + 2 == 34 processes.) The longest running was test_multiprocessing_spawn.test_processes at 2:18. But test_super took 10:13 and test_free_threading took 13:37. These both need to be broken up into one or more directories with multiple files in each, which each file running faster than the longest 'other' test. Several other tests, including multiprocessing have been broken up in the last year to allow testing to complete faster on multicore machines. (I don't know what label, if any, might be added for test_super.) <!-- gh-linked-prs --> ### Linked PRs * gh-124434 * gh-124438 * gh-124439 * gh-124468 * gh-124491 * gh-124585 <!-- /gh-linked-prs -->
5a605660745d32a9b9f4208666889c702527208c
b169cf394fe70dfbc7bbe22ae703be3b21845add