summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-58124: Avoid CP_UTF8 in UnicodeDecodeError (GH-137415) (#137461)Miss Islington (bot)2025-08-061-1/+1
| | | | | | | | | | gh-58124: Avoid CP_UTF8 in UnicodeDecodeError (GH-137415) Fix name of the Python encoding in Unicode errors of the code page codec: use "cp65000" and "cp65001" instead of "CP_UTF7" and "CP_UTF8" which are not valid Python code names. (cherry picked from commit ce1b747ff68754635b7b12870dfc527184ee3b39) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] GH-133136: Revise QSBR to reduce excess memory held (gh-135473) ↵Neil Schemenauer2025-07-302-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | (gh-136480) The free threading build uses QSBR to delay the freeing of dictionary keys and list arrays when the objects are accessed by multiple threads in order to allow concurrent reads to proceed with holding the object lock. The requests are processed in batches to reduce execution overhead, but for large memory blocks this can lead to excess memory usage. Take into account the size of the memory block when deciding when to process QSBR requests. Also track the amount of memory being held by QSBR for mimalloc pages. Advance the write sequence if this memory exceeds a limit. Advancing the sequence will allow it to be freed more quickly. Process the held QSBR items from the "eval breaker", rather than from `_PyMem_FreeDelayed()`. This gives a higher chance that the global read sequence has advanced enough so that items can be freed. (cherry picked from commit 113de8545ffe74a4a1dddb9351fa1cbd3562b621) Co-authored-by: Neil Schemenauer <nas-github@arctrix.com> Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-134411: assert `PyLong_FromLong(x) != NULL` when `x` is known to ↵Miss Islington (bot)2025-07-211-0/+4
| | | | | | | | | | | be small (GH-134415) (#136911) gh-134411: assert `PyLong_FromLong(x) != NULL` when `x` is known to be small (GH-134415) Since `PyLong_From Long(PY_MONITORING_DEBUGGER_ID)` falls to `small_int` case and can't return `NULL`. Added `assert`s for extra confidence. https://github.com/python/cpython/issues/134411#issuecomment-2897653868 (cherry picked from commit cf19b6435d02dd7be11b84a44f4a8a9f1a935b15) Co-authored-by: Sergey Muraviov <smurav@mail.ru>
* [3.13] gh-136541: Fix several problems of perf trampolines in x86_64 and ↵Pablo Galindo Salgado2025-07-113-41/+144
| | | | | | | | | | | aarch64 (GH-136500) (#136545) This commit fixes the following problems: * The x86_64 trampolines are not preserving frame pointers * The hardcoded offsets to the code segment from the FDE only worked properly for x64_64 * The CIE data was not following conventions of aarch64 * The eh_frame for aarch64 was not fully correct (cherry picked from commit 236f733d8ffb3d587e1167fa0a0248c24512e7fd)
* [3.13] gh-109700: fix interpreter finalization while handling memory error ↵Miss Islington (bot)2025-07-071-7/+7
| | | | | | | | (GH-136342) (#136353) gh-109700: fix interpreter finalization while handling memory error (GH-136342) (cherry picked from commit 0c3e3da19570424649c33c0c2c29dc12541935e7) Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* [3.13] gh-135871: Fix needless spinning in `_PyMutex_LockTimed` with zero ↵Sam Gross2025-06-251-1/+1
| | | | | | | | | timeout (gh-135872) (gh-135947) The free threading build could spin unnecessarily on `_Py_yield()` if the initial compare and swap failed. (cherry picked from commit cbfaf41caf135b8598a560854cd59e992a2ccfed) Co-authored-by: Joseph Tibbertsma <josephtibbertsma@gmail.com>
* [3.13] gh-135855: Raise TypeError When Passing Non-dict Object to ↵Brian Schubert2025-06-241-0/+1
| | | | | `_interpreters.set___main___attrs` (gh-135903) (cherry picked from commit 4e6f0d116e, AKA gh-135856)
* [3.13] GH-135171: Roll back all fixes for GH-127682 as they are not suitable ↵T. Wouters2025-06-111-3/+18
| | | | for 3.13 (#135390)
* [3.13] gh-128605: Add branch protections for x86_64 in asm_trampoline.S ↵stratakis2025-06-112-0/+26
| | | | | | | | | | | | (#128606) (#135353) Apply Intel Control-flow Technology for x86-64 on asm_trampoline.S. Required for mitigation against return-oriented programming (ROP) and Call or Jump Oriented Programming (COP/JOP) attacks. Manual application is required for the assembly files. See also: https://sourceware.org/annobin/annobin.html/Test-cf-protection.html
* [3.13] Heavily comment Python/perf_jit_trampoline.c to improve ↵Miss Islington (bot)2025-06-091-385/+1029
| | | | maintainability (GH-134527) (#135300)
* [3.13] gh-128605: Revert "Add branch protections for x86_64 in ↵Miss Islington (bot)2025-06-062-27/+0
| | | | | | | | | | | asm_tr…ampoline.S (GH-128606) (GH-135077)" (GH-135175) (GH-135203) [3.14] gh-128605: Revert "Add branch protections for x86_64 in asm_tr…ampoline.S (GH-128606) (GH-135077)" (GH-135175) This reverts commit 899cca6dbf76bf3e06a99f60a5f996ad6ba0761f, which broke buildbots. (cherry picked from commit b477e21d5cb85bc764d6d9d18d122aa703d7b548) Co-authored-by: Petr Viktorin <encukou@gmail.com>
* [3.13] gh-128605: Add branch protections for x86_64 in asm_trampoline.S ↵Miss Islington (bot)2025-06-032-0/+27
| | | | | | | | | | | | | | | | | (GH-128606) (GH-135077) (#135083) [3.14] gh-128605: Add branch protections for x86_64 in asm_trampoline.S (GH-128606) (GH-135077) Apply Intel Control-flow Technology for x86-64 on asm_trampoline.S. Required for mitigation against return-oriented programming (ROP) and Call or Jump Oriented Programming (COP/JOP) attacks. Manual application is required for the assembly files. See also: https://sourceware.org/annobin/annobin.html/Test-cf-protection.html (cherry picked from commit 899cca6dbf76bf3e06a99f60a5f996ad6ba0761f) Co-authored-by: stratakis <cstratak@redhat.com>
* [3.13] GH-128161: Fix refleak introduced in GH-134788 (GH-134799)Mark Shannon2025-05-271-1/+3
|
* [3.13] gh-128161: Remove redundant GET_ITER from list comprehension code ↵Mark Shannon2025-05-271-17/+2
| | | | (backport of GH-134778) (GH-134788)
* [3.13] gh-134100: Fix use-after-free in `PyImport_ImportModuleLevelObject` ↵Miss Islington (bot)2025-05-181-1/+3
| | | | | | | | (GH-134117) (#134172) gh-134100: Fix use-after-free in `PyImport_ImportModuleLevelObject` (GH-134117) (cherry picked from commit 4e9005d32ff466925f40af410f2ea6bf2329bcf8) Co-authored-by: Nico-Posada <102486290+Nico-Posada@users.noreply.github.com>
* [3.13] gh-133441: Fix STORE_ATTR_WITH_HINT bytecode (#133446)Victor Stinner2025-05-112-2/+3
| | | | | Deoptimize if the dict is a dict subclass. Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* gh-133597: Fix memory leak if error occurred in ↵Miss Islington (bot)2025-05-081-0/+3
| | | | | | | _sys_getwindowsversion_from_kernel32 (GH-133598) (cherry picked from commit 0ec8fc83a83914d2ae97e52529e98ce63aaf831c) Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
* [3.13] GH-127682: Backport GH-132351 (GH-132384)Mark Shannon2025-04-291-3/+1
| | | Only call `__iter__` once in generator expressions
* [3.13] gh-132909: handle overflow for `'K'` format in `do_mkvalue` ↵Bénédikt Tran2025-04-251-1/+2
| | | | | (GH-132911) (#132932) (cherry picked from commit 3fa024dec32e2ff86baf3dd7e14a0b314855327c)
* [3.13] gh-130070: Fix `exec(<string>, closure=<non-None>)` unexpected path ↵Bartosz Sławecki2025-04-171-0/+1
| | | | | | | | | | | (GH-130071) (#132627) gh-130070: Fix `exec(<string>, closure=<non-None>)` unexpected path (#130071) Fixed an assertion error (so, it could be reproduced only in builds with assertions enabled) for `exec` when the `source` argument is a string and the `closure` argument is not `None`. Co-authored-by: sobolevn <mail@sobolevn.me> (cherry picked from commit 954b2cf031fb84ff3386251d5c45281f47229003)
* [3.13] gh-124476: Fix decoding from the locale encoding in the C.UTF-8 ↵Serhiy Storchaka2025-04-141-9/+1
| | | | | locale (GH-132477) (ПР-132528) (cherry picked from commit 102f825c5112cbe6985edc0971822b07bd778135)
* [3.13] gh-131927: Prevent emitting compiler warnings twice (GH-131993) ↵Tomas R.2025-04-132-2/+24
| | | | | | (GH-132463) (cherry picked from commit 3d08c8ad20dfabd4864be139cd9c2eb5602ccdfe)
* [3.13] gh-131998: Fix `NULL` dereference when using an unbound method ↵Peter Bierma2025-04-083-0/+18
| | | | | | | | | | | descriptor in a specialized code path (GH-132000) (#132262) (cherry picked from commit ac3c439cdfee8452f2bcceacd67a1f4e423ac3cf) Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: sobolevn <mail@sobolevn.me> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Mark Shannon <mark@hotpy.org>
* [3.13] gh-130775: Allow negative locations in `ast` (GH-130795) (#132243)sobolevn2025-04-081-4/+2
| | | | | (cherry picked from commit bc5233b6a5cdd8f77a4737ce317f94110869c082) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] GH-127953: Make line number lookup O(1) regardless of the size of the ↵Mark Shannon2025-04-072-152/+198
| | | | | code object (#129127) GH-127953: Make line number lookup O(1) regardless of the size of the code object (GH-128350)
* [3.13] gh-131988: Fix a multithreaded scaling regression (#131989)Sam Gross2025-04-071-2/+2
| | | | | | | | | | | | gh-131988: Fix a multithreaded scaling regression The 3.13 free threaded build immortalizes certain objects to avoid reference count contention. In gh-127114 the condition was unintentionally changed to happen when the first thread was created instead of the first non-main thread. The `interp->gc.immortalize` field is then cleared again during `_PyGC_Init()`. Change the condition so that we check if we should immortalize objects using deferred reference counting whenever a non-main thread is created.
* [3.13] gh-132011: Fix crash on invalid `CALL_LIST_APPEND` deoptimization ↵sobolevn2025-04-062-2/+2
| | | | | | | | | | (GH-132018) (#132161) * [3.13] gh-132011: Fix crash on invalid `CALL_LIST_APPEND` deoptimization (GH-132018) (cherry picked from commit c0661df42ad20e488dbfa3e0fec22462833fc3d6) Co-authored-by: sobolevn <mail@sobolevn.me> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* [3.13] gh-130115: fix thread identifiers for 32-bit musl (GH-130391) (GH-132089)Miss Islington (bot)2025-04-041-9/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CPython's pthread-based thread identifier relies on pthread_t being able to be represented as an unsigned integer type. This is true in most Linux libc implementations where it's defined as an unsigned long, however musl typedefs it as a struct *. If the pointer has the high bit set and is cast to PyThread_ident_t, the resultant value can be sign-extended [0]. This can cause issues when comparing against threading._MainThread's identifier. The main thread's identifier value is retrieved via _get_main_thread_ident which is backed by an unsigned long which truncates sign extended bits. >>> hex(threading.main_thread().ident) '0xb6f33f3c' >>> hex(threading.current_thread().ident) '0xffffffffb6f33f3c' Work around this by conditionally compiling in some code for non-glibc based Linux platforms that are at risk of sign-extension to return a PyLong based on the main thread's unsigned long thread identifier if the current thread is the main thread. [0]: https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Arrays-and-pointers-implementation.html --------- (cherry picked from commit 72123063ddee84bb2c9d591a23f420997e35af5a) Signed-off-by: Vincent Fazio <vfazio@gmail.com> Co-authored-by: Vincent Fazio <vfazio@gmail.com>
* [3.13] gh-128632: fix segfault on nested __classdict__ type param ↵Tomasz Pytel2025-04-042-13/+32
| | | | | | | (GH-128744) (#132085) (cherry picked from commit 891c61c1fa480928dd60cce8bbc8764630c95025) Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
* [3.13] gh-132002: Fix crash of `ContextVar` on unhashable `str` subtype ↵Miss Islington (bot)2025-04-021-7/+6
| | | | | | | | (GH-132003) (#132007) gh-132002: Fix crash of `ContextVar` on unhashable `str` subtype (GH-132003) (cherry picked from commit ab2a3dda1d3b6668162a847bf5b6aca2855a3416) Co-authored-by: sobolevn <mail@sobolevn.me>
* [3.13] gh-131818: Add imply `-P` in `-I`'s help message (GH-131819) (#131822)Miss Islington (bot)2025-03-281-1/+1
| | | | | | gh-131818: Add imply `-P` in `-I`'s help message (GH-131819) (cherry picked from commit 8bd88e2827b2a887c2ea8e5ed0c0575704bfacdf) Co-authored-by: Hang <bebound@gmail.com>
* [3.13] gh-131740: Update PyUnstable_GC_VisitObjects to traverse perm … ↵Donghee Na2025-03-261-10/+20
| | | | | | | | | (gh-131754) * [3.13] gh-131740: Update PyUnstable_GC_VisitObjects to traverse perm gen (gh-131744) (cherry picked from commit 7bb41aef4b7b8f3c3f07c11b801c5b7f8afaac7f) * fix
* [3.13] gh-131670: Fix crash in `anext()` when `__anext__` is sync and raises ↵Miss Islington (bot)2025-03-241-0/+3
| | | | | | | | | (GH-131682) (#131686) gh-131670: Fix crash in `anext()` when `__anext__` is sync and raises (GH-131682) (cherry picked from commit 929afd1d6ee4fb89ac818037effe6577947103de) Co-authored-by: sobolevn <mail@sobolevn.me> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* [3.13] gh-117657: Fix TSAN data race in _PyEval_SetTrace assertion ↵Miss Islington (bot)2025-03-211-1/+1
| | | | | | | | (gh-131561) (#131564) The `sys_tracing_threads` variable should be read inside `LOCK_SETUP()`. (cherry picked from commit 0de5e0c5442abddbe17481ef450e4abc992058f5) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-130382: add missing `_PyReftracerTrack` to ceval `Py_DECREF` ↵Sam Gross2025-03-141-0/+1
| | | | | | | (GH-130689) (#131195) (cherry picked from commit c5abded09995f208b21ebaf012185ca5acb0180b) Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
* [3.13] gh-131141: fix data race in instrumentation while registering ↵Kumar Aditya2025-03-131-3/+4
| | | | callback (#131166)
* [3.13] gh-130940: Remove PyConfig.use_system_logger (#131129)Russell Keith-Magee2025-03-132-34/+12
| | | | | | | Removes ``PyConfig.use_system_logger``, resolving an ABI incompatibility introduced in 3.13.2. Changes the default behavior of iOS to *always* direct stdout/stderr to the system log.
* [3.13] gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (GH-131044) ↵Miss Islington (bot)2025-03-112-2/+6
| | | | | | | (#131084) (cherry picked from commit de8818ae233b8e7722aa5d6f91d4b5a04bd039df) Co-authored-by: Max Bachmann <kontakt@maxbachmann.de>
* [3.13] gh-117174: Add a new route in linecache to fetch interactive source ↵Miss Islington (bot)2025-03-101-1/+1
| | | | | | | | code (GH-117500) (#131060) gh-117174: Add a new route in linecache to fetch interactive source code (GH-117500) (cherry picked from commit a931a8b32415f311008dbb3f09079aae1e6d7a3d) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.13] gh-130794: Process interpreter QSBR queue in _PyMem_AbandonDelayed. ↵Sam Gross2025-03-041-0/+1
| | | | | | | (gh-130808) (#130857) This avoids a case where the interpreter's queue of memory to be freed could grow rapidly if there are many short lived threads. (cherry picked from commit 2f6e0e9f7001769be746ee96356656d3ebdc7f96)
* [3.13] gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738) ↵Bénédikt Tran2025-03-032-5/+4
| | | | | | | | | | | | | | | | (#130756) gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738) 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` (this caused some build failures when compiling CPython with `zig cc`). (cherry-picked from commit 214562ed4ddc248b007f718ed92ebcc0c3669611) --------- Co-authored-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
* [3.13] Postpone <stdbool.h> inclusion after Python.h (#130641) (#130675)Victor Stinner2025-02-283-6/+5
| | | | | | | | | | | | | Postpone <stdbool.h> inclusion after Python.h (#130641) 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. (cherry picked from commit 830f04b5056db92ba96387db0a778dcd19a39522) Co-authored-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
* [3.13] gh-130163: Fix crashes related to PySys_GetObject() (GH-130503) ↵Serhiy Storchaka2025-02-2511-140/+371
| | | | | | | | | | (GH-130556) 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(). (cherry picked from commit 0ef4ffeefd1737c18dc9326133c7894d58108c2e)
* [3.13] Update manpage environment variables and command line arguments ↵Miss Islington (bot)2025-02-131-0/+2
| | | | | | | (GH-129623) (#130078) Co-authored-by: Stefano Rivera <stefano@rivera.za.net> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* [3.13] gh-129533: Update PyGC_Enable/Disable/IsEnabled to use atomic ↵Donghee Na2025-02-061-11/+7
| | | | | | | operat… (gh-129756) gh-129533: Update PyGC_Enable/Disable/IsEnabled to use atomic operation (gh-129563) (cherry picked from commit b184abf074c0e1f379a238f07da5616460f36b93)
* [3.13] gh-129732: Fix race on `shared->array` in qsbr code under ↵Sam Gross2025-02-061-6/+6
| | | | | | | | free-threading (gh-129738) (gh-129747) The read of `shared->array` should happen under the lock to avoid a race. (cherry picked from commit b4ff8b22b3066b814c3758f87eaddfa923e657ed) Co-authored-by: Peter Hawkins <phawkins@google.com>
* [3.13] gh-126108: Fix potential null pointer dereference in ↵Miss Islington (bot)2025-01-311-3/+4
| | | | | | | | `PySys_AddWarnOptionUnicode` (GH-126118) (#129520) gh-126108: Fix potential null pointer dereference in `PySys_AddWarnOptionUnicode` (GH-126118) (cherry picked from commit fad36bf38248130bc48b81a5e7c31a7649a6456e) Co-authored-by: Valery Fedorenko <federicovalenso@gmail.com>
* [3.13] gh-128799: Add frame of except* to traceback when wrapping a naked ↵Irit Katriel2025-01-301-0/+12
| | | | exception (#128971) (#129299)
* [3.13] gh-128679: Clear the ref tracer in _PyTraceMalloc_Stop() (#129258)Victor Stinner2025-01-241-0/+2
| | | _PyTraceMalloc_Stop() now calls PyRefTracer_SetTracer(NULL, NULL).
* [3.13] gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191) (#129217)Victor Stinner2025-01-232-6/+29
| | | | | | | | | | | | | gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191) Support calling PyTraceMalloc_Track() and PyTraceMalloc_Untrack() during late Python finalization. * Call _PyTraceMalloc_Fini() later in Python finalization. * Test also PyTraceMalloc_Untrack() without the GIL * PyTraceMalloc_Untrack() now gets the GIL. * Test also PyTraceMalloc_Untrack() in test_tracemalloc_track_race(). (cherry picked from commit 46c7e13c055c218e18b0424efc60965e6a5fe6ea)