summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
...
* gh-130080: move _Py_EnsureArrayLargeEnough to a separate header so it can be ↵Irit Katriel2025-03-133-44/+69
| | | | used outside of the compiler (#130930)
* gh-111178: Fix function signatures in misc files (#131180)Victor Stinner2025-03-131-2/+3
|
* gh-130940: Modify default behavior of `PyConfig.use_system_logger` to enable ↵Russell Keith-Magee2025-03-131-3/+12
| | | | | on iOS (#131172) Modify default behavior of use_system_log to enable on iOS.
* gh-126835: Avoid creating unnecessary tuple when looking for constant ↵Yan Yanchii2025-03-122-94/+132
| | | | sequence during constant folding (#131054)
* gh-131141: fix data race in instrumentation while registering callback (#131142)Kumar Aditya2025-03-121-10/+13
|
* gh-115999: Add free-threaded specialization for FOR_ITER (#128798)T. Wouters2025-03-126-44/+311
| | | | Add free-threaded versions of existing specialization for FOR_ITER (list, tuples, fast range iterators and generators), without significantly affecting their thread-safety. (Iterating over shared lists/tuples/ranges should be fine like before. Reusing iterators between threads is not fine, like before. Sharing generators between threads is a recipe for significant crashes, like before.)
* gh-81267: Correct time.sleep() error message (#131055)Stan Ulbrych2025-03-121-15/+19
|
* gh-122029: Do not unpack method for legacy tracing anymore (#130898)Tian Gao2025-03-111-13/+0
|
* gh-111178: Change Argument Clinic signature for METH_O (#130682)Victor Stinner2025-03-114-8/+47
| | | Use "PyObject*" for METH_O functions to fix an undefined behavior.
* gh-130396: Fix thread sanitizer crashes on stack overflow tests (gh-130966)Sam Gross2025-03-111-0/+5
| | | | Thread sanitizer will often crash if a test uses more than half the stack.
* gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (#131044)Max Bachmann2025-03-112-2/+6
| | | | | * Add missing guards for WIN32_LEAN_AND_MEAN * add missing whitespaces
* gh-117174: Add a new route in linecache to fetch interactive source code ↵Pablo Galindo Salgado2025-03-101-1/+1
| | | | (#117500)
* GH-123044: Give the `POP_TOP` after a case test a location in the body, not ↵Mark Shannon2025-03-103-6/+20
| | | | the pattern. (GH-130627)
* GH-127705: Use `_PyStackRef`s in the default build. (GH-127875)Mark Shannon2025-03-108-150/+233
|
* GH-128534: Fix behavior of branch monitoring for `async for` (GH-130847)Mark Shannon2025-03-077-13/+40
| | | * Both branches in a pair now have a common source and are included in co_branches
* gh-130920: Fix data race in STORE_SUBSCR_LIST_INT (#130923)Sam Gross2025-03-063-3/+6
| | | | | | The write of the item to the list needs to use an atomic operation in the free threading build. Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
* gh-124878: Fix race conditions during interpreter finalization (#130649)Sam Gross2025-03-064-57/+79
| | | | | | | | | | | | | | | | | | | | The PyThreadState field gains a reference count field to avoid issues with PyThreadState being a dangling pointer to freed memory. The refcount starts with a value of two: one reference is owned by the interpreter's linked list of thread states and one reference is owned by the OS thread. The reference count is decremented when the thread state is removed from the interpreter's linked list and before the OS thread calls `PyThread_hang_thread()`. The thread that decrements it to zero frees the `PyThreadState` memory. The `holds_gil` field is moved out of the `_status` bit field, to avoid a data race where on thread calls `PyThreadState_Clear()`, modifying the `_status` bit field while the OS thread reads `holds_gil` when attempting to acquire the GIL. The `PyThreadState.state` field now has `_Py_THREAD_SHUTTING_DOWN` as a possible value. This corresponds to the `_PyThreadState_MustExit()` check. This avoids race conditions in the free threading build when checking `_PyThreadState_MustExit()`.
* gh-130860: Fix width calculation, when separators in fractional part (GH-130865)Sergey B Kirpichev2025-03-061-17/+18
| | | | This amends f39a07be47
* GH-130903: typo in optimizer DSL for _GUARD_BOTH_UNICODE (#130904)Jamie Phan2025-03-062-2/+2
| | | Typo introduced in gh-118910.
* gh-130574: renumber RESUME opcode from 149 to 128 (GH-130685)Tomasz Pytel2025-03-061-42/+42
|
* gh-118331: Fix a couple of issues when list allocation fails (#130811)mpage2025-03-052-0/+4
| | | | | | | | | | | | | | | | * Fix use after free in list objects Set the items pointer in the list object to NULL after the items array is freed during list deallocation. Otherwise, we can end up with a list object added to the free list that contains a pointer to an already-freed items array. * Mark `_PyList_FromStackRefStealOnSuccess` as escaping I think technically it's not escaping, because the only object that can be decrefed if allocation fails is an exact list, which cannot execute arbitrary code when it is destroyed. However, this seems less intrusive than trying to special cases objects in the assert in `_Py_Dealloc` that checks for non-null stackpointers and shouldn't matter for performance.
* GH-127705: better double free message. (GH-130785)Mark Shannon2025-03-052-13/+52
| | | | | * Add location information when accessing already closed stackref * Add #def option to track closed stackrefs to provide precise information for use after free and double frees.
* gh-130794: Process interpreter QSBR queue in _PyMem_AbandonDelayed. (gh-130808)Sam Gross2025-03-041-0/+1
| | | | | This avoids a case where the interpreter's queue of memory to be freed could grow rapidly if there are many short lived threads.
* GH-130415: Narrow str to "" based on boolean tests (GH-130476)Amit Lavon2025-03-043-2/+5
|
* GH-130415: Narrow int to 0 based on boolean tests (GH-130772)Klaus1172025-03-043-2/+5
|
* gh-130790: Remove references about unicode's readiness from comments (#130801)Sergey Miryanov2025-03-033-10/+0
|
* gh-129173: refactor `PyCodec_BackslashReplaceErrors` into separate functions ↵Bénédikt Tran2025-03-031-41/+70
| | | | | | (#129895) The logic of `PyCodec_BackslashReplaceErrors` is now split into separate functions, each of which handling a specific exception type.
* gh-129173: simplify `PyCodec_XMLCharRefReplaceErrors` logic (#129894)Bénédikt Tran2025-03-031-60/+39
| | | | | | | Writing the decimal representation of a Unicode codepoint only requires to know the number of digits. --------- Co-authored-by: Petr Viktorin <encukou@gmail.com>
* docs: internal notes have moved, correct references (#130762)Ned Batchelder2025-03-031-1/+1
|
* GH-130415: Use boolean guards to narrow types to values in the JIT (GH-130659)Brandt Bucher2025-03-024-163/+272
|
* gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738)Hugo Beauzée-Luyssen2025-03-024-9/+8
| | | | | Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not included first and when we are in a platform-agnostic context. This is to avoid having features defined by `stdbool.h` before those decided by `Python.h`.
* GH-130296: Avoid stack transients in four instructions. (GH-130310)Mark Shannon2025-02-287-534/+226
| | | | | | | | | * Combine _GUARD_GLOBALS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_MODULE_FROM_KEYS into _LOAD_GLOBAL_MODULE * Combine _GUARD_BUILTINS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_BUILTINS_FROM_KEYS into _LOAD_GLOBAL_BUILTINS * Combine _CHECK_ATTR_MODULE_PUSH_KEYS and _LOAD_ATTR_MODULE_FROM_KEYS into _LOAD_ATTR_MODULE * Remove stack transient in LOAD_ATTR_WITH_HINT
* gh-130605: Use relaxed atomics to set the GIL switch interval (gh-130654)Sam Gross2025-02-281-3/+6
| | | | The interval may be concurrently read by a thread attempting to acquire the GIL.
* Postpone <stdbool.h> inclusion after Python.h (#130641)Hugo Beauzée-Luyssen2025-02-283-6/+5
| | | | | | | Remove inclusions prior to Python.h. <stdbool.h> will cause <features.h> to be included before Python.h can define some macros to enable some additional features, causing multiple types not to be defined down the line.
* gh-130595: Fix leak in WITH_EXCEPT_START error case (GH-130626)Petr Viktorin2025-02-283-7/+3
| | | Co-authored-by: Ken Jin <kenjin@python.org>
* gh-130091: Reorder `_PyThreadState_Attach` to avoid data race (gh-130092)Sam Gross2025-02-271-2/+1
| | | | | | | | | | | | This moves `tstate_activate()` down to avoid a data race in the free threading build on the `_PyRuntime`'s thread-local `autoTSSkey`. This key is deleted during runtime finalization, which may happen concurrently with a call to `_PyThreadState_Attach`. The earlier `tstate_try/wait_attach` ensures that the thread is blocked before it attempts to access the deleted `autoTSSkey`. This fixes a TSAN reported data race in `test_threading.test_import_from_another_thread`.
* gh-130421: Fix data race on timebase initialization (gh-130592)Sam Gross2025-02-272-48/+31
| | | | | | Windows and macOS require precomputing a "timebase" in order to convert OS timestamps into nanoseconds. Retrieve and compute this value during runtime initialization to avoid data races when accessing the time.
* GH-128534: Instrument branches for `async for` loops. (GH-130569)Mark Shannon2025-02-275-3/+70
|
* gh-111178: Fix function signatures in instruction_sequence.c (#130591)Victor Stinner2025-02-261-6/+9
|
* gh-111178: Fix function signatures in symtable.c (#130589)Victor Stinner2025-02-261-6/+8
|
* gh-130595: Keep traceback alive for WITH_EXCEPT_START (#130562)Dino Viehland2025-02-263-16/+10
| | | Keep traceback alive for WITH_EXCEPT_START
* gh-130163: Fix crashes related to PySys_GetObject() (GH-130503)Serhiy Storchaka2025-02-2511-170/+370
| | | | | | | | The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed reference, has been replaced by using one of the following functions, which return a strong reference and distinguish a missing attribute from an error: _PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(), _PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
* gh-122029: Move monitoring after method expand for CALL_KW (GH-130488)Tian Gao2025-02-252-28/+26
|
* gh-87790: support thousands separators for formatting fractional part of ↵Sergey B Kirpichev2025-02-251-29/+131
| | | | | | | | | | | | | | floats (#125304) ```pycon >>> f"{123_456.123_456:_._f}" # Whole and fractional '123_456.123_456' >>> f"{123_456.123_456:_f}" # Integer component only '123_456.123456' >>> f"{123_456.123_456:._f}" # Fractional component only '123456.123_456' >>> f"{123_456.123_456:.4_f}" # with precision '123456.1_235' ```
* gh-129173: refactor `PyCodec_ReplaceErrors` into separate functions (#129893)Bénédikt Tran2025-02-251-40/+83
| | | | The logic of `PyCodec_ReplaceErrors` is now split into separate functions, each of which handling a specific exception type.
* GH-130396: Use computed stack limits on linux (GH-130398)Mark Shannon2025-02-2511-796/+642
| | | | | | | | | | | * Implement C recursion protection with limit pointers for Linux, MacOS and Windows * Remove calls to PyOS_CheckStack * Add stack protection to parser * Make tests more robust to low stacks * Improve error messages for stack overflow
* GH-91079: Revert "GH-91079: Implement C stack limits using addresses, not ↵Petr Viktorin2025-02-2410-623/+796
| | | | | | | | | counters. (GH-130007)" for now (GH130413) Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now Unfortunatlely, the change broke some buildbots. This reverts commit 2498c22fa0a2b560491bc503fa676585c1a603d0.
* gh-128627: Skip wasm-gc on iOS Safari where it's broken (#130418)Łukasz Langa2025-02-231-3/+13
| | | | | | As of iOS 18.3.1, enabling wasm-gc breaks the interpreter. This disables the wasm-gc trampoline on iOS. Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
* gh-126835: Move constant unaryop & binop folding to CFG (#129550)Yan Yanchii2025-02-212-286/+334
|
* gh-111924: Fix data races when swapping allocators (gh-130287)Sam Gross2025-02-205-126/+86
| | | | | | | | | | | | | | | CPython current temporarily changes `PYMEM_DOMAIN_RAW` to the default allocator during initialization and shutdown. The motivation is to ensure that core runtime structures are allocated and freed using the same allocator. However, modifying the current allocator changes global state and is not thread-safe even with the GIL. Other threads may be allocating or freeing objects use PYMEM_DOMAIN_RAW; they are not required to hold the GIL to call PyMem_RawMalloc/PyMem_RawFree. This adds new internal-only functions like `_PyMem_DefaultRawMalloc` that aren't affected by calls to `PyMem_SetAllocator()`, so they're appropriate for Python runtime initialization and finalization. Use these calls in places where we previously swapped to the default raw allocator.