summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-120298: Fix use-after-free in `list_richcompare_impl` (GH-120303) ↵Miss Islington (bot)2024-06-111-1/+8
| | | | | | | | | (#120340) gh-120298: Fix use-after-free in `list_richcompare_impl` (GH-120303) (cherry picked from commit 141babad9b4eceb83371bf19ba3a36b50dd05250) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-120155: Fix copy/paste error in HAVE_SUBOFFSETS_IN_LAST_DIM() ↵Miss Islington (bot)2024-06-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | (GH-120228) (#120238) gh-120155: Fix copy/paste error in HAVE_SUBOFFSETS_IN_LAST_DIM() (GH-120228) Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of memoryobject.c, but use its 'view' parameter instead. Fix the Coverity issue: Error: COPY_PASTE_ERROR (CWE-398): Python-3.12.2/Objects/memoryobject.c:273:14: original: ""dest->suboffsets + (dest->ndim - 1)"" looks like the original copy. Python-3.12.2/Objects/memoryobject.c:274:14: copy_paste_error: ""dest"" in ""src->suboffsets + (dest->ndim - 1)"" looks like a copy-paste error. Python-3.12.2/Objects/memoryobject.c:274:14: remediation: Should it say ""src"" instead? GH- 272| assert(dest->ndim > 0 && src->ndim > 0); GH- 273| return (!HAVE_SUBOFFSETS_IN_LAST_DIM(dest) && GH- 274|-> !HAVE_SUBOFFSETS_IN_LAST_DIM(src) && GH- 275| dest->strides[dest->ndim-1] == dest->itemsize && GH- 276| src->strides[src->ndim-1] == src->itemsize); (cherry picked from commit 90b75405260467814c93738a3325645918d4ea51) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-119999: Fix potential race condition in ↵Miss Islington (bot)2024-06-041-8/+11
| | | | | | | | | | | `_Py_ExplicitMergeRefcount` (GH-120000) (#120073) We need to write to `ob_ref_local` and `ob_tid` before `ob_ref_shared`. Once we mark `ob_ref_shared` as merged, some other thread may free the object because the caller also passes in `-1` as `extra` to give up its only reference. (cherry picked from commit 4055577221f5f52af329e87f31d81bb8fb02c504) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-111389: Add PyHASH_MULTIPLIER constant (GH-119214) (#119334)Miss Islington (bot)2024-06-041-1/+1
| | | | | | gh-111389: Add PyHASH_MULTIPLIER constant (GH-119214) (cherry picked from commit f6da790122fdae1a28f444edfbb55202d6829cd1) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-117398: Use Per-Interpreter State for the _datetime Static Types ↵Miss Islington (bot)2024-06-036-98/+194
| | | | | | | | | | | (gh-120009) We make use of the same mechanism that we use for the static builtin types. This required a few tweaks. This change is the final piece needed to make _datetime support multiple interpreters. I've updated the module slot accordingly. (cherry picked from commit 105f22ea46ac16866e6df18ebae2a8ba422b7f45, AKA gh-119929) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* [3.13] gh-117657: Fix race involving immortalizing objects (GH-119927) (#120005)Sam Gross2024-06-032-3/+3
| | | | | | | | | | | The free-threaded build currently immortalizes objects that use deferred reference counting (see gh-117783). This typically happens once the first non-main thread is created, but the behavior can be suppressed for tests, in subinterpreters, or during a compile() call. This fixes a race condition involving the tracking of whether the behavior is suppressed. (cherry picked from commit 47fb4327b5c405da6df066dcaa01b7c1aefab313)
* [3.13] gh-117657: Fix data races report by TSAN unicode-hash (gh-119907) ↵Miss Islington (bot)2024-06-031-8/+11
| | | | | | | | (gh-119963) gh-117657: Fix data races report by TSAN unicode-hash (gh-119907) (cherry picked from commit 0594a27e5f1d87d59fa8a761dd8ca9df4e42816d) Co-authored-by: Donghee Na <donghee.na@python.org>
* [3.13] gh-74929: PEP 667 C API documentation (gh-119892)Miss Islington (bot)2024-06-011-2/+7
| | | | | | | | | | | * Add docs for new APIs * Add soft-deprecation notices * Add What's New porting entries * Update comments referencing `PyFrame_LocalsToFast()` to mention the proxy instead * Other related cleanups found when looking for refs to the deprecated APIs (cherry picked from commit 3859e09e3d92d004978dd838f0511364e7edfb94) Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
* [3.13] gh-109218: Improve documentation for the complex() constructor ↵Miss Islington (bot)2024-05-302-6/+12
| | | | | | | | | | | | | | | | | | (GH-119687) (GH-119803) * Remove the equivalence with real+imag*1j which can be incorrect in corner cases (non-finite numbers, the sign of zeroes). * Separately document the three roles of the constructor: parsing a string, converting a number, and constructing a complex from components. * Document positional-only parameters of complex(), float(), int() and bool() as positional-only. * Add examples for complex() and int(). * Specify the grammar of the string for complex(). * Improve the grammar of the string for float(). * Describe more explicitly the behavior when real and/or imag arguments are complex numbers. (This will be deprecated in future.) (cherry picked from commit ec1ba264607b2b7b98d2602f5536a1d02981efc6) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-119525: Fix deadlock with `_PyType_Lookup` and the GIL (GH-119527) ↵Miss Islington (bot)2024-05-291-4/+7
| | | | | | | | | | | | | | | (#119746) The deadlock only affected the free-threaded build and only occurred when the GIL was enabled at runtime. The `Py_DECREF(old_name)` call might temporarily release the GIL while holding the type seqlock. Another thread may spin trying to acquire the seqlock while holding the GIL. The deadlock occurred roughly 1 in ~1,000 runs of `pool_in_threads.py` from `test_multiprocessing_pool_circular_import`. (cherry picked from commit c22323cd1c200ca1b22c47af95f67c4b2d661fe7) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-119011: `type.__type_params__` now return an empty tuple ↵Miss Islington (bot)2024-05-281-0/+4
| | | | | | | (GH-119296) (#119678) (cherry picked from commit 6b240c2308a044e38623900ccb8fa58c3549d4ae) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.13] gh-111999: Fix the signature of str.format_map() (GH-119540) (#119543)Miss Islington (bot)2024-05-251-1/+1
| | | | | (cherry picked from commit 08e65430aafa1047029e6f132a5f748c415bda14) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] GH-117195: Avoid assertion error in `object.__sizeof__` (GH-117220) ↵Miss Islington (bot)2024-05-231-2/+5
| | | | (GH-119456)
* [3.13] gh-117657: Fix missing atomic in dict_resize (GH-119312) (#119417)Miss Islington (bot)2024-05-221-1/+1
| | | | | | | | gh-117657: Fix missing atomic in dict_resize (GH-119312) Fix missing atomic in dict_resize (cherry picked from commit 2b3fb767bea1f96c9e0523f6cc341b40f0fa1ca1) Co-authored-by: Dino Viehland <dinoviehland@meta.com>
* [3.13] gh-119247: Add macros to use PySequence_Fast safely in free-threaded ↵Miss Islington (bot)2024-05-221-3/+5
| | | | | | | | | | | build (GH-119315) (#119419) Add `Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST` and `Py_END_CRITICAL_SECTION_SEQUENCE_FAST` macros and update `str.join` to use them. Also add a regression test that would crash reliably without this patch. (cherry picked from commit baf347d91643a83483bae110092750d39471e0c2) Co-authored-by: Josh {*()} Rosenberg <26495692+MojoVampire@users.noreply.github.com>
* [3.13] gh-119053: Implement the fast path for list.__getitem__ (gh-119112) ↵Miss Islington (bot)2024-05-211-5/+10
| | | | | | | | (gh-119309) gh-119053: Implement the fast path for list.__getitem__ (gh-119112) (cherry picked from commit ab4263a82abe8b684d8ad1edf7c7c6ec286ff756) Co-authored-by: Donghee Na <donghee.na@python.org>
* [3.13] gh-118921: Add `copy()` method for `FrameLocalsProxy` (GH-118923) ↵Miss Islington (bot)2024-05-101-0/+19
| | | | | | | (#118933) (cherry picked from commit 35c436186b849f8f2f9fb866c59015c9d034d448) Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
* [3.13] Rename `notimplemented_methods` into `nodefault_methods` (GH-118896) ↵Miss Islington (bot)2024-05-101-4/+4
| | | | | | | | (#118898) Rename `notimplemented_methods` into `nodefault_methods` (GH-118896) (cherry picked from commit 004db2170ecfc27fc8ceea29fee0a10c1b7dafdf) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* Fix some missing null checks. (GH-118721)Miss Islington (bot)2024-05-101-5/+8
| | | | | (cherry picked from commit 7e6fcab20003b07621dc02ea78d6ea2fda500371) Co-authored-by: Steve Dower <steve.dower@python.org>
* [3.13] gh-118561: Fix crash involving list.extend in free-threaded build ↵Miss Islington (bot)2024-05-091-1/+2
| | | | | | | | | | | | (GH-118723) (#118863) The `list_preallocate_exact` function did not zero initialize array contents. In the free-threaded build, this could expose uninitialized memory to concurrent readers between the call to `list_preallocate_exact` and the filling of the array contents with items. (cherry picked from commit 2402715e10d00ef60fad2948d8461559d084eb36) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-118849: Fix "code will never be executed" warning in ↵Miss Islington (bot)2024-05-091-1/+1
| | | | | | | | `dictobject.c` (GH-118850) (#118859) gh-118849: Fix "code will never be executed" warning in `dictobject.c` (GH-118850) (cherry picked from commit 82abe75e77129bebb3c13d807e8040f6924194f6) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.13] gh-117657: Fix data races when writing / reading `ob_gc_bits` ↵Miss Islington (bot)2024-05-081-1/+1
| | | | | | | | | | (GH-118292) (#118796) Use relaxed atomics when reading / writing to the field. There are still a few places in the GC where we do not use atomics. Those should be safe as the world is stopped. (cherry picked from commit cb6f75a32ca2649c6cc1cabb0301eb783efbd55b) Co-authored-by: mpage <mpage@meta.com>
* gh-118746: Fix crash in frame_getlocals and _PyFrame_GetLocals (#118748)Tian Gao2024-05-081-0/+18
| | | | We don't know how to create an unoptimized frame with f_locals == NULL, but they are seen in the wild, and this fixes the crash.
* gh-110209: Add __class_getitem__ for generator and coroutine (#110212)James Hilton-Balfe2024-05-071-0/+2
|
* gh-118527: Intern code consts in free-threaded build (#118667)Sam Gross2024-05-072-14/+294
| | | | | | We already intern and immortalize most string constants. In the free-threaded build, other constants can be a source of reference count contention because they are shared by all threads running the same code objects.
* gh-112075: Fix race in constructing dict for instance (#118499)Dino Viehland2024-05-062-70/+74
|
* gh-118527: Intern code name and filename on default build (#118576)Sam Gross2024-05-061-2/+0
| | | | Interned and non-interned strings are treated differently by `marshal`, so be consistent between the default and free-threaded build.
* GH-115709: Invalidate executors when a local variable is changed via ↵Mark Shannon2024-05-061-1/+2
| | | | | frame.f_locals (#118639) Also fix unrelated assert in debug Tier2/JIT builds.
* gh-118362: Fix thread safety around lookups from the type cache in the face ↵Dino Viehland2024-05-064-118/+263
| | | | | | | of concurrent mutators (#118454) Add _PyType_LookupRef and use incref before setting attribute on type Makes setting an attribute on a class and signaling type modified atomic Avoid adding re-entrancy exposing the type cache in an inconsistent state by decrefing after type is updated
* GH-117714: implement athrow().close() and asend().close() using throw ↵Thomas Grainger2024-05-061-4/+38
| | | | | | | | | | | | | | | | | | (GH-117906) * GH-117714: replace athrow().close() and asend().close() stubs with implimentations * test athrow().close() and asend().close() raises RuntimeError * 📜🤖 Added by blurb_it. * Update Objects/genobject.c Co-authored-by: Petr Viktorin <encukou@gmail.com> --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-116322: Rename PyModule_ExperimentalSetGIL to PyUnstable_Module_SetGIL ↵Petr Viktorin2024-05-061-1/+1
| | | | (GH-118645)
* gh-118609: Add proper error check for framelocalsproxy (#118615)Tian Gao2024-05-061-46/+99
|
* gh-74929: Make containment checks more efficient in `FrameLocalsProxy` (#118624)Tian Gao2024-05-061-10/+19
| | | Properly implement the `sq_contains` slot for frame locals proxy containment checks.
* gh-118605: Fix reference leak in FrameLocalsProxy (#118607)Tian Gao2024-05-051-3/+28
| | | Also add some error checks.
* gh-74929: Remove undesirable DECREF in PEP 667 implementation (#118583)Tian Gao2024-05-051-1/+0
| | | | With tests.
* gh-74929: Implement PEP 667 (GH-115153)Tian Gao2024-05-042-199/+662
|
* gh-118527: Intern filename, name, and qualname in code objects. (#118558)Sam Gross2024-05-031-0/+5
| | | | | | This interns the strings for `co_filename`, `co_name`, and `co_qualname` on codeobjects in the free-threaded build. This partially addresses a reference counting bottleneck when creating closures concurrently. The closures take the name and qualified name from the code object.
* gh-117657: Disable the function/code cache in free-threaded builds (#118301)mpage2024-05-032-0/+16
| | | | This is only used by the specializing interpreter and the tier 2 optimizer, both of which are disabled in free-threaded builds.
* gh-118527: Use deferred reference counting for C functions on modules (#118529)Sam Gross2024-05-031-0/+1
| | | | | This addresses a scaling bottleneck in the free-threaded build when calling functions like `math.floor()` concurrently from multiple threads.
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-032-0/+36
| | | | | | | | | | | | | | This PR adds the ability to enable the GIL if it was disabled at interpreter startup, and modifies the multi-phase module initialization path to enable the GIL when loading a module, unless that module's spec includes a slot indicating it can run safely without the GIL. PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148. A warning will be issued up to once per interpreter for the first GIL-using module that is loaded. If `-v` is given, a shorter message will be printed to stderr every time a GIL-using module is loaded (including the first one that issues a warning).
* gh-116126: Implement PEP 696 (#116129)Jelle Zijlstra2024-05-032-47/+450
| | | | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* gh-116738: Make `_codecs` module thread-safe (#117530)Brett Simmers2024-05-021-1/+5
| | | | | | | | | | | | | | | The module itself is a thin wrapper around calls to functions in `Python/codecs.c`, so that's where the meaningful changes happened: - Move codecs-related state that lives on `PyInterpreterState` to a struct declared in `pycore_codecs.h`. - In free-threaded builds, add a mutex to `codecs_state` to synchronize operations on `search_path`. Because `search_path_mutex` is used as a normal mutex and not a critical section, we must be extremely careful with operations called while holding it. - The codec registry is explicitly initialized as part of `_PyUnicode_InitEncodings` to simplify thread-safety.
* gh-118519: Fix empty weakref list check (#118520)Dino Viehland2024-05-021-1/+1
| | | Fix empty list check
* gh-117657: Fix TSAN list set failure (#118260)Dino Viehland2024-05-021-3/+6
| | | | | | | | | | | * Fix TSAN list set failure * Relaxed atomic is sufficient, add targetted test * More list * Remove atomic assign in list * Fixup white space
* gh-93502: Add new C-API functions to trace object creation and destruction ↵Pablo Galindo Salgado2024-05-021-6/+31
| | | | (#115945)
* GH-118095: Make invalidating and clearing executors memory safe (GH-118459)Mark Shannon2024-05-011-1/+2
|
* GH-117881: fix athrow().throw()/asend().throw() concurrent access (GH-117882)Thomas Grainger2024-05-011-0/+37
|
* gh-118335: Configure Tier 2 interpreter at build time (#118339)Guido van Rossum2024-05-012-0/+10
| | | | | | | | | | | | | | | | | | | | | | The code for Tier 2 is now only compiled when configured with `--enable-experimental-jit[=yes|interpreter]`. We drop support for `PYTHON_UOPS` and -`Xuops`, but you can disable the interpreter or JIT at runtime by setting `PYTHON_JIT=0`. You can also build it without enabling it by default using `--enable-experimental-jit=yes-off`; enable with `PYTHON_JIT=1`. On Windows, the `build.bat` script supports `--experimental-jit`, `--experimental-jit-off`, `--experimental-interpreter`. In the C code, `_Py_JIT` is defined as before when the JIT is enabled; the new variable `_Py_TIER2` is defined when the JIT *or* the interpreter is enabled. It is actually a bitmask: 1: JIT; 2: default-off; 4: interpreter.
* [gh-117657] Fix some issues with TSAN in typeobject (#118249)Dino Viehland2024-04-301-6/+11
| | | Fix some racing reads in typebobject.c
* gh-117657: Fix small issues with instrumentation and TSAN (#118064)Dino Viehland2024-04-301-3/+5
| | | Small TSAN fixups for instrumentation