summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* gh-128400: Only show the current thread in `Py_FatalError` on the ↵Peter Bierma2025-01-131-0/+4
| | | | free-threaded build (#128758)
* GH-128682: Stronger checking of `PyStackRef_CLOSE` and `DEAD`. (GH-128683)Mark Shannon2025-01-133-102/+114
|
* GH-128685: Specialize (rather than quicken) LOAD_CONST into ↵Mark Shannon2025-01-137-16/+57
| | | | LOAD_CONST_[IM]MORTAL (GH-128708)
* gh-128627: Emscripten: Use wasm-gc based call adaptor if available (#128628)Hood Chatham2025-01-121-52/+177
| | | | | | Replaces the trampoline mechanism in Emscripten with an implementation that uses a recently added feature of wasm-gc instead of JS type reflection, when that feature is available.
* gh-128717: Stop-the-world when setting the recursion limit (#128741)Peter Bierma2025-01-121-0/+2
|
* Make the Python CLI error message style more consistent (GH-128129)9cel2025-01-111-2/+2
|
* gh-111178: fix UBSan failures in `Python/bltinmodule.c` (GH-128235)Bénédikt Tran2025-01-101-30/+51
| | | | | * fix UBSan failures for `filterobject` * fix UBSan failures for `mapobject` * fix UBSan failures for `zipobject`
* gh-128629: Add Py_PACK_VERSION and Py_PACK_FULL_VERSION (GH-128630)Petr Viktorin2025-01-091-0/+17
|
* Remove unnecessary LIST_TO_TUPLE conversions (GH-126558)Brandt Bucher2025-01-081-0/+7
|
* gh-111178: fix UBSan failures in `Python/context.c` (GH-128242)Bénédikt Tran2025-01-081-53/+68
| | | | | | * fix UBSan failures for `PyContext` * fix UBSan failures for `PyContextVar` * fix UBSan failures for `PyContextToken` * fix UBSan failures for `_PyContextTokenMissing`
* gh-111178: fix UBSan failures in `Python/hamt.c` (GH-128247)Bénédikt Tran2025-01-081-90/+84
| | | | | | | * fix UBSan failures for `PyHamtObject` * fix UBSan failures for `PyHamtNode_Array` * fix UBSan failures for `PyHamtNode_Collision` * fix UBSan failures for `PyHamtNode_Bitmap`
* GH-127809: Fix the JIT's understanding of ** (GH-127844)Brandt Bucher2025-01-085-26/+152
|
* gh-115999: Add free-threaded specialization for COMPARE_OP (#126410)T. Wouters2025-01-073-12/+9
| | | | | Add free-threaded specialization for COMPARE_OP, and tests for COMPARE_OP specialization in general. Co-authored-by: Donghee Na <donghee.na92@gmail.com>
* gh-128146: Exclude os/log.h import on older macOS versions. (#128165)Russell Keith-Magee2025-01-071-11/+22
| | | | Reworks the handling of Apple system log handling to account for older macOS versions that don't provide os-log.
* GH-128533: Add `NOT_TAKEN` instruction after bytecode optimization. (GH-128554)Mark Shannon2025-01-062-13/+4
|
* GH-128375: Better instrument for `FOR_ITER` (GH-128445)Mark Shannon2025-01-069-111/+212
|
* gh-127350: Add Py_fopen() and Py_fclose() functions (#127821)Victor Stinner2025-01-065-34/+53
|
* Remove asserts that confuse `enum _framestate` with `enum _frameowner` ↵Anders Kaseorg2025-01-021-2/+0
| | | | | | | | | | | | (GH-124148) The `owner` field of `_PyInterpreterFrame` is supposed to be a member of `enum _frameowner`, but `FRAME_CLEARED` is a member of `enum _framestate`. At present, it happens that `FRAME_CLEARED` is not numerically equal to any member of `enum _frameowner`, but that could change in the future. The code that incorrectly assigned `owner = FRAME_CLEARED` was deleted in commit a53cc3f49463e50cb3e2b839b3a82e6bf7f73fee (GH-116687). Remove the incorrect checks for `owner != FRAME_CLEARED` as well.
* gh-128277: make globals variables thread safe in socket module (#128286)Kumar Aditya2024-12-311-3/+3
|
* gh-128262: Allow specialization of calls to classes with __slots__ (GH-128263)Ken Jin2024-12-314-10/+16
|
* gh-119786: Mention `InternalDocs/interpreter.md` instead of non-existing ↵Yan Yanchii2024-12-301-1/+1
| | | | | | | | `adaptive.md` (#128329) `Python/specialize.c`: Mention `InternalDocs/interpreter.md` instead of non-existing `adaptive.md` Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* gh-119180: Set the name of the param to __annotate__ to "format" (#124730)Jelle Zijlstra2024-12-301-0/+27
|
* gh-128195: Add `_REPLACE_WITH_TRUE` to the tier2 optimizer (GH-128203)Yan Yanchii2024-12-232-1/+5
| | | Add `_REPLACE_WITH_TRUE` to the tier2 optimizer
* gh-114203: Optimise simple recursive critical sections (#128126)T. Wouters2024-12-231-7/+17
| | | | | | | Add a fast path to (single-mutex) critical section locking _iff_ the mutex is already held by the currently active, top-most critical section of this thread. This can matter a lot for indirectly recursive critical sections without intervening critical sections.
* gh-128049: Fix type confusion bug with the return value of a custom ↵Nico-Posada2024-12-201-2/+19
| | | | ExceptionGroup split function (#128079)
* GH-127705: Add debug mode for `_PyStackRef`s inspired by HPy debug mode ↵Mark Shannon2024-12-207-31/+269
| | | | (GH-128121)
* gh-128030: Avoid error from PyModule_GetFilenameObject for non-module (#128047)Shantanu2024-12-201-1/+1
| | | | | I missed the extra `PyModule_Check` in #127660 because I was looking at 3.12 as the base implementation for import from. This meant that I missed the `PyModuleCheck` introduced in #112661.
* gh-127274: Defer nested methods (#128012)mpage2024-12-192-0/+9
| | | | | | | Methods (functions defined in class scope) are likely to be cleaned up by the GC anyway. Add a new code flag, `CO_METHOD`, that is set for functions defined in a class scope. Use that when deciding to defer functions.
* gh-115999: Specialize `STORE_ATTR` in free-threaded builds. (gh-127838)Neil Schemenauer2024-12-195-177/+342
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add `_PyDictKeys_StringLookupSplit` which does locking on dict keys and use in place of `_PyDictKeys_StringLookup`. * Change `_PyObject_TryGetInstanceAttribute` to use that function in the case of split keys. * Add `unicodekeys_lookup_split` helper which allows code sharing between `_Py_dict_lookup` and `_PyDictKeys_StringLookupSplit`. * Fix locking for `STORE_ATTR_INSTANCE_VALUE`. Create `_GUARD_TYPE_VERSION_AND_LOCK` uop so that object stays locked and `tp_version_tag` cannot change. * Pass `tp_version_tag` to `specialize_dict_access()`, ensuring the version we store on the cache is the correct one (in case of it changing during the specalize analysis). * Split `analyze_descriptor` into `analyze_descriptor_load` and `analyze_descriptor_store` since those don't share much logic. Add `descriptor_is_class` helper function. * In `specialize_dict_access`, double check `_PyObject_GetManagedDict()` in case we race and dict was materialized before the lock. * Avoid borrowed references in `_Py_Specialize_StoreAttr()`. * Use `specialize()` and `unspecialize()` helpers. * Add unit tests to ensure specializing happens as expected in FT builds. * Add unit tests to attempt to trigger data races (useful for running under TSAN). * Add `has_split_table` function to `_testinternalcapi`.
* GH-122548: Implement branch taken and not taken events for sys.monitoring ↵Mark Shannon2024-12-198-125/+353
| | | | (GH-122564)
* gh-115999: Enable BINARY_SUBSCR_GETITEM for free-threaded build (gh-127737)Donghee Na2024-12-196-57/+70
|
* gh-128033: change `PyMutex_LockFast` to take `PyMutex` as argument (#128054)Kumar Aditya2024-12-181-1/+1
| | | Change `PyMutex_LockFast` to take `PyMutex` as argument.
* gh-126742: Add _PyErr_SetLocaleString, use it for gdbm & dlerror messages ↵Bénédikt Tran2024-12-171-0/+9
| | | | | | | | (GH-126746) - Add a helper to set an error from locale-encoded `char*` - Use the helper for gdbm & dlerror messages Co-authored-by: Victor Stinner <vstinner@python.org>
* Free arena on _PyCompile_AstOptimize failure in Py_CompileStringObject ↵Berker Peksag2024-12-161-0/+1
| | | | | | (GH-127910) After commit 10a91d7e9 introduced arena cleanup, commit 2dfbd4f36 removed the free call when _PyCompile_AstOptimize fails.
* gh-127864: Fix compiler warning (-Wstringop-truncation) (GH-127878)Tomas R.2024-12-161-2/+3
|
* gh-115999: Specialize loading attributes from modules in free-threaded ↵mpage2024-12-137-91/+222
| | | | | | | | | builds (#127711) We use the same approach that was used for specialization of LOAD_GLOBAL in free-threaded builds: _CHECK_ATTR_MODULE is renamed to _CHECK_ATTR_MODULE_PUSH_KEYS; it pushes the keys object for the following _LOAD_ATTR_MODULE_FROM_KEYS (nee _LOAD_ATTR_MODULE). This arrangement avoids having to recheck the keys version. _LOAD_ATTR_MODULE is renamed to _LOAD_ATTR_MODULE_FROM_KEYS; it loads the value from the keys object pushed by the preceding _CHECK_ATTR_MODULE_PUSH_KEYS at the cached index.
* GH-126833: Dumps graphviz representation of executor graph. (GH-126880)Mark Shannon2024-12-134-2/+218
|
* gh-126868: Add freelist for compact int objects (GH-126865)Pieter Eendebak2024-12-133-36/+37
|
* gh-127865: Fix build failure for systems without thread local support ↵velemas2024-12-121-4/+4
| | | | | | (GH-127866) This PR fixes the build issue introduced by the commit 628f6eb from GH-112207 on systems without thread local support.
* gh-115999: Specialize `CALL_KW` in free-threaded builds (#127713)mpage2024-12-114-35/+26
| | | | | | | | | | | | | * Enable specialization of CALL_KW * Fix bug pushing frame in _PY_FRAME_KW `_PY_FRAME_KW` pushes a pointer to the new frame onto the stack for consumption by the next uop. When pushing the frame fails, we do not want to push the result, `NULL`, to the stack because it is not a valid stackref. This works in the default build because `PyStackRef_NULL` and `NULL` are the same value, so the `PyStackRef_XCLOSE()` in the error handler ignores it. In the free-threaded build the values are not the same; `PyStackRef_XCLOSE()` will attempt to decref a null pointer.
* gh-126491: Revert "GH-126491: Lower heap size limit with faster marking ↵Petr Viktorin2024-12-101-144/+157
| | | | | | | | (GH-127519)" (GH-127770) Revert "GH-126491: Lower heap size limit with faster marking (GH-127519)" This reverts commit 023b7d2141467017abc27de864f3f44677768cb3, which introduced a refleak.
* gh-127651: Use __file__ in diagnostics if origin is missing (#127660)Shantanu2024-12-101-3/+19
| | | | | | | See the left hand side in https://github.com/python/cpython/pull/123929/files#diff-c22186367cbe20233e843261998dc027ae5f1f8c0d2e778abfa454ae74cc59deL2840-L2849 --------- Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-126925: Modify how iOS test results are gathered (#127592)Russell Keith-Magee2024-12-093-0/+98
| | | | | | | Adds a `use_system_log` config item to enable stdout/stderr redirection for Apple platforms. This log streaming is then used by a new iOS test runner script, allowing the display of test suite output at runtime. The iOS test runner script can be used by any Python project, not just the CPython test suite.
* gh-125610: Fix `STORE_ATTR_INSTANCE_VALUE` specialization check (GH-125612)Sam Gross2024-12-061-1/+4
| | | | The `STORE_ATTR_INSTANCE_VALUE` opcode doesn't support objects with non-NULL managed dictionaries, so don't specialize to that op in that case.
* GH-126491: Lower heap size limit with faster marking (GH-127519)Mark Shannon2024-12-061-157/+144
| | | | | | | * Faster marking of reachable objects * Changes calculation of work to do and work done. * Merges transitive closure calculations
* gh-115999: Enable specialization of `CALL` instructions in free-threaded ↵mpage2024-12-036-71/+107
| | | | | | | | | | | | | | | | | | | | | | builds (#127123) The CALL family of instructions were mostly thread-safe already and only required a small number of changes, which are documented below. A few changes were needed to make CALL_ALLOC_AND_ENTER_INIT thread-safe: Added _PyType_LookupRefAndVersion, which returns the type version corresponding to the returned ref. Added _PyType_CacheInitForSpecialization, which takes an init method and the corresponding type version and only populates the specialization cache if the current type version matches the supplied version. This prevents potentially caching a stale value in free-threaded builds if we race with an update to __init__. Only cache __init__ functions that are deferred in free-threaded builds. This ensures that the reference to __init__ that is stored in the specialization cache is valid if the type version guard in _CHECK_AND_ALLOCATE_OBJECT passes. Fix a bug in _CREATE_INIT_FRAME where the frame is pushed to the stack on failure. A few other miscellaneous changes were also needed: Use {LOCK,UNLOCK}_OBJECT in LIST_APPEND. This ensures that the list's per-object lock is held while we are appending to it. Add missing co_tlbc for _Py_InitCleanup. Stop/start the world around setting the eval frame hook. This allows us to read interp->eval_frame non-atomically and preserves the behavior of _CHECK_PEP_523 documented below.
* gh-127271: Replace use of PyCell_GET/SET (gh-127272)Neil Schemenauer2024-12-031-1/+6
| | | | | | | | | | | | | | | | | | * Replace uses of `PyCell_GET` and `PyCell_SET`. These macros are not safe to use in the free-threaded build. Use `PyCell_GetRef()` and `PyCell_SetTakeRef()` instead. * Since `PyCell_GetRef()` returns a strong rather than borrowed ref, some code restructuring was required, e.g. `frame_get_var()` returns a strong ref now. * Add critical sections to `PyCell_GET` and `PyCell_SET`. * Move critical_section.h earlier in the Python.h file. * Add `PyCell_GET` to the free-threading howto table of APIs that return borrowed refs. * Add additional unit tests for free-threading.
* gh-115999: Add free-threaded specialization for `SEND` (gh-127426)Neil Schemenauer2024-12-033-15/+8
| | | | | No additional thread safety changes are required. Note that sending to a generator that is shared between threads is currently not safe in the free-threaded build.
* gh-115999: Specialize `LOAD_SUPER_ATTR` in free-threaded builds (gh-127128)Neil Schemenauer2024-12-034-19/+9
| | | | | | Use existing helpers to atomically modify the bytecode. Add unit tests to ensure specializing is happening as expected. Add test_specialize.py that can be used with ThreadSanitizer to detect data races. Fix thread safety issue with cell_set_contents().
* gh-117657: TSAN Fix races in `PyMember_Get` and `PyMember_Set` for C ↵Daniele Parmeggiani2024-12-031-46/+51
| | | | extensions (GH-123211)