summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* 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
* gh-118272: Clear generator frame's locals when the generator is closed (#118277)Irit Katriel2024-04-301-0/+1
| | | Co-authored-by: Thomas Grainger <tagrain@gmail.com>
* gh-118331: Handle errors in _PyObject_SetManagedDict (#118334)Sam Gross2024-04-292-12/+19
| | | | | When detaching a dict, the `copy_values` call may fail due to out-of-memory errors. This can be triggered by test_no_memory in test_repl.
* gh-117783: Immortalize objects that use deferred reference counting (#118112)Sam Gross2024-04-291-0/+7
| | | | | | | | | Deferred reference counting is not fully implemented yet. As a temporary measure, we immortalize objects that would use deferred reference counting to avoid multi-threaded scaling bottlenecks. This is only performed in the free-threaded build once the first non-main thread is started. Additionally, some tests, including refleak tests, suppress this behavior.
* gh-118331: Don't raise an error if tuple allocation fails when clearing ↵mpage2024-04-291-1/+3
| | | | | | | | | | weakrefs (#118338) It's not safe to raise an exception in `PyObject_ClearWeakRefs()` if one is not already set, since it may be called by `_Py_Dealloc()`, which requires that the active exception does not change. Additionally, make sure we clear the weakrefs even when tuple allocation fails.
* gh-107674: Lazy load line number to improve performance of tracing (GH-118127)Tian Gao2024-04-291-4/+12
|
* gh-112075: _Py_dict_lookup needs to lock shared keys (#117528)Dino Viehland2024-04-251-127/+158
| | | | | Lock shared keys in `Py_dict_lookup` and use thread-safe lookup in `insertdict` Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-117657: Fixes a few small TSAN issues in dictobject (#118200)Dino Viehland2024-04-251-11/+14
| | | | Fixup TSAN errors for dict
* gh-112069: Do not require lock if the set has never been exposed. (gh-118069)Donghee Na2024-04-251-0/+7
|
* gh-117578: Introduce _PyType_GetModuleByDef2 private function (GH-117661)neonene2024-04-251-7/+45
| | | | Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* GH-118095: Handle `RETURN_GENERATOR` in tier 2 (GH-118180)Mark Shannon2024-04-251-5/+0
|
* gh-108191: Add support of positional argument in SimpleNamespace constructor ↵Serhiy Storchaka2024-04-241-3/+21
| | | | | | | (GH-108195) SimpleNamespace({'a': 1, 'b': 2}) and SimpleNamespace([('a', 1), ('b', 2)]) are now the same as SimpleNamespace(a=1, b=2).
* GH-117536: GH-117894: fix athrow().throw(...) unawaited warning (GH-117851)Thomas Grainger2024-04-241-1/+8
|
* gh-95754: Better error when script shadows a standard library or third party ↵Shantanu2024-04-231-53/+191
| | | | module (#113769)
* gh-112075: Make instance attributes stored in inline "dict" thread safe ↵Dino Viehland2024-04-223-103/+357
| | | | | (#114742) Make instance attributes stored in inline "dict" thread safe on free-threaded builds
* ``Objects/typeobject.c``: Fix typo (#118126)Kirill Podoprigora2024-04-211-1/+1
|
* [gh-117657] _Py_MergeZeroLocalRefcount isn't loading ob_ref_shared with ↵Dino Viehland2024-04-191-1/+1
| | | | | strong enough semantics (#118111) Use acquire for load of ob_ref_shared
* Fix a typo in dictobject.c documentation (#117515)Noah Kim2024-04-191-1/+1
|
* gh-117657: use relaxed loads for checking dict keys immortality (#118067)Dino Viehland2024-04-191-2/+2
| | | Use relaxed load to check if dictkeys are immortal
* setobject: remove out of date docstring info (GH-118048)Rostyslav Lobov2024-04-191-1/+1
|
* gh-112069: Make PySet_GET_SIZE to be atomic safe. (gh-118053)Donghee Na2024-04-181-1/+0
| | | gh-112069: Make PySet_GET_SIZE to be atomic operation
* gh-112069: Add _PySet_NextEntryRef to be thread-safe. (gh-117990)Donghee Na2024-04-183-5/+21
|
* fix formatting of literal in docstring of int.from_bytes and int.to_bytes ↵Jens Hedegaard Nielsen2024-04-182-7/+7
| | | | (#117847)