summaryrefslogtreecommitdiffstats
path: root/Include
Commit message (Collapse)AuthorAgeFilesLines
* gh-119182: Add PyUnicodeWriter_WriteUCS4() function (#120849)Victor Stinner2024-06-241-0/+4
|
* gh-119521: Use `PyAPI_DATA`, not `extern`, for `_PyExc_IncompleteInputError` ↵Petr Viktorin2024-06-241-1/+2
| | | | (GH-120955)
* gh-119521: Rename IncompleteInputError to _IncompleteInputError and remove ↵Pablo Galindo Salgado2024-06-242-1/+4
| | | | | | | from public API/ABI (GH-119680) Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-120834: fix type of *_iframe field in _PyGenObject_HEAD declaration (#120835)Irit Katriel2024-06-244-40/+47
|
* GH-107803: double linked list implementation for asyncio tasks (GH-107804)Kumar Aditya2024-06-224-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * linked list * add tail optmiization to linked list * wip * wip * wip * more fixes * finally it works * add tests * remove weakreflist * add some comments * reduce code duplication in _asynciomodule.c * address some review comments * add invariants about the state of the linked list * add better explanation * clinic regen * reorder branches for better branch prediction * Update Modules/_asynciomodule.c * Apply suggestions from code review Co-authored-by: Itamar Oren <itamarost@gmail.com> * fix capturing of eager tasks * add comment to task finalization * fix tests and couple c implmentation to c task improved linked-list logic and more comments * fix test --------- Co-authored-by: Itamar Oren <itamarost@gmail.com>
* gh-119344: Make critical section API public (#119353)Sam Gross2024-06-214-150/+219
| | | | | | | | | | This makes the following macros public as part of the non-limited C-API for locking a single object or two objects at once. * `Py_BEGIN_CRITICAL_SECTION(op)` / `Py_END_CRITICAL_SECTION()` * `Py_BEGIN_CRITICAL_SECTION2(a, b)` / `Py_END_CRITICAL_SECTION2()` The supporting functions and structs used by the macros are also exposed for cases where C macros are not available.
* gh-119182: Add PyUnicodeWriter_DecodeUTF8Stateful() (#120639)Victor Stinner2024-06-211-0/+10
| | | | | | Add PyUnicodeWriter_WriteWideChar() and PyUnicodeWriter_DecodeUTF8Stateful() functions. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-113993: Allow interned strings to be mortal, and fix related issues ↵Petr Viktorin2024-06-215-818/+1549
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-120520) * Add an InternalDocs file describing how interning should work and how to use it. * Add internal functions to *explicitly* request what kind of interning is done: - `_PyUnicode_InternMortal` - `_PyUnicode_InternImmortal` - `_PyUnicode_InternStatic` * Switch uses of `PyUnicode_InternInPlace` to those. * Disallow using `_Py_SetImmortal` on strings directly. You should use `_PyUnicode_InternImmortal` instead: - Strings should be interned before immortalization, otherwise you're possibly interning a immortalizing copy. - `_Py_SetImmortal` doesn't handle the `SSTATE_INTERNED_MORTAL` to `SSTATE_INTERNED_IMMORTAL` update, and those flags can't be changed in backports, as they are now part of public API and version-specific ABI. * Add private `_only_immortal` argument for `sys.getunicodeinternedsize`, used in refleak test machinery. * Make sure the statically allocated string singletons are unique. This means these sets are now disjoint: - `_Py_ID` - `_Py_STR` (including the empty string) - one-character latin-1 singletons Now, when you intern a singleton, that exact singleton will be interned. * Add a `_Py_LATIN1_CHR` macro, use it instead of `_Py_ID`/`_Py_STR` for one-character latin-1 singletons everywhere (including Clinic). * Intern `_Py_STR` singletons at startup. * For free-threaded builds, intern `_Py_LATIN1_CHR` singletons at startup. * Beef up the tests. Cover internal details (marked with `@cpython_only`). * Add lots of assertions Co-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>
* gh-117511: Make PyMutex public in the non-limited API (#117731)Sam Gross2024-06-208-75/+89
|
* Fix typos in comments (#120481)Xie Yanbo2024-06-202-2/+2
|
* GH-119462: Enforce invariants of type versioning (GH-120731)Mark Shannon2024-06-191-1/+1
| | | | * Remove uses of Py_TPFLAGS_VALID_VERSION_TAG
* gh-120600: Make Py_TYPE() opaque in limited C API 3.14 (#120601)Victor Stinner2024-06-181-9/+19
| | | | In the limited C API 3.14 and newer, Py_TYPE() is now implemented as an opaque function call to hide implementation details.
* gh-118789: Add `PyUnstable_Object_ClearWeakRefsNoCallbacks` (#118807)Sam Gross2024-06-182-1/+3
| | | | | | | | | | | | This exposes `PyUnstable_Object_ClearWeakRefsNoCallbacks` as an unstable C-API function to provide a thread-safe mechanism for clearing weakrefs without executing callbacks. Some C-API extensions need to clear weakrefs without calling callbacks, such as after running finalizers like we do in subtype_dealloc. Previously they could use `_PyWeakref_ClearRef` on each weakref, but that's not thread-safe in the free-threaded build. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* GH-120507: Lower the `BEFORE_WITH` and `BEFORE_ASYNC_WITH` instructions. ↵Mark Shannon2024-06-187-136/+148
| | | | | | | | | (#120640) * Remove BEFORE_WITH and BEFORE_ASYNC_WITH instructions. * Add LOAD_SPECIAL instruction * Reimplement `with` and `async with` statements using LOAD_SPECIAL
* gh-119182: Add PyUnicodeWriter C API (#119184)Victor Stinner2024-06-171-2/+35
|
* gh-119933: Improve ``SyntaxError`` message for invalid type parameters ↵Bénédikt Tran2024-06-171-5/+26
| | | | | expressions (#119976) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* GH-120619: Clean up `RETURN_VALUE` instruction (GH-120624)Mark Shannon2024-06-173-35/+35
| | | | | * Rename _POP_FRAME to _RETURN_VALUE as it returns a value as well as popping a frame. * Remove remaining _POP_FRAMEs
* gh-83754: Use the Py_TYPE() macro (#120599)Victor Stinner2024-06-172-6/+6
| | | | Don't access directly PyObject.ob_type, but use the Py_TYPE() macro instead.
* gh-117657: Make PyType_HasFeature (exported version) atomic (#120484)Ken Jin2024-06-151-1/+5
| | | Make PyType_HasFeature (exported version) atomic
* gh-120161: Fix a Crash in the _datetime Module (gh-120182)Eric Snow2024-06-141-9/+15
| | | | | | | In gh-120009 I used an atexit hook to finalize the _datetime module's static types at interpreter shutdown. However, atexit hooks are executed very early in finalization, which is a problem in the few cases where a subclass of one of those static types is still alive until the final GC collection. The static builtin types don't have this probably because they are finalized toward the end, after the final GC collection. To avoid the problem for _datetime, I have applied a similar approach here. Also, credit goes to @mgorny and @neonene for the new tests. FYI, I would have liked to take a slightly cleaner approach with managed static types, but wanted to get a smaller fix in first for the sake of backporting. I'll circle back to the cleaner approach with a future change on the main branch.
* gh-117657: Make PyType_HasFeature atomic (GH-120210)Ken Jin2024-06-132-1/+4
| | | Make PyType_HasFeature atomic
* gh-71587: Drop local reference cache to `_strptime` module in `_datetime` ↵neonene2024-06-124-0/+6
| | | | | (gh-120224) The _strptime module object was cached in a static local variable (in the datetime.strptime() implementation). That's a problem when it crosses isolation boundaries, such as reinitializing the runtme or between interpreters. This change fixes the problem by dropping the static variable, instead always relying on the normal sys.modules cache (via PyImport_Import()).
* gh-120029: remove unused macros in ``symtable.c`` (#120222)Bénédikt Tran2024-06-121-4/+0
| | | | Co-authored-by: Carl Meyer <carl@oddbird.net> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-117657: Make Py_TYPE and Py_SET_TYPE thread safe (GH-120165)Ken Jin2024-06-122-1/+12
| | | | Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
* gh-120029: make `symtable.Symbol.__repr__` correctly reflect the compiler's ↵Bénédikt Tran2024-06-121-1/+1
| | | | | | | | | | flags, add methods (#120099) Expose :class:`symtable.Symbol` methods :meth:`~symtable.Symbol.is_free_class`, :meth:`~symtable.Symbol.is_comp_iter` and :meth:`~symtable.Symbol.is_comp_cell`. --------- Co-authored-by: Carl Meyer <carl@oddbird.net>
* gh-120326: Include <intrin.h> on Windows with Free Threading (#120329)Kirill Podoprigora2024-06-111-0/+4
|
* gh-119180: PEP 649 compiler changes (#119361)Jelle Zijlstra2024-06-116-8/+10
|
* gh-119258: Eliminate Type Guards in Tier 2 Optimizer with Watcher (GH-119365)Saul Shanabrook2024-06-082-3/+17
| | | | | | | Co-authored-by: parmeggiani <parmeggiani@spaziodati.eu> Co-authored-by: dpdani <git@danieleparmeggiani.me> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com> Co-authored-by: Ken Jin <kenjin@python.org>
* Fix typos in comments (#120188)Xie Yanbo2024-06-0711-11/+11
|
* gh-117657: Fix TSAN race involving import lock (#118523)Sam Gross2024-06-062-16/+14
| | | | | This adds a `_PyRecursiveMutex` type based on `PyMutex` and uses that for the import lock. This fixes some data races in the free-threaded build and generally simplifies the import lock code.
* gh-117657: Fix race involving GC and heap initialization (#119923)Sam Gross2024-06-041-0/+1
| | | | | | | | | | | | The `_PyThreadState_Bind()` function is called before the first `PyEval_AcquireThread()` so it's not synchronized with the stop the world GC. We had a race where `gc_visit_heaps()` might visit a thread's heap while it's being initialized. Use a simple atomic int to avoid visiting heaps for threads that are not yet fully initialized (i.e., before `tstate_mimalloc_bind()` is called). The race was reproducible by running: `python Lib/test/test_importlib/partial/pool_in_threads.py`.
* gh-119613: Soft deprecate the Py_MEMCPY() macro (#120020)Victor Stinner2024-06-041-0/+1
| | | Use directly memcpy() instead.
* gh-117398: Use Per-Interpreter State for the _datetime Static Types (gh-119929)Eric Snow2024-06-032-11/+39
| | | | | | | We make use of the same mechanism that we use for the static builtin types. This required a few tweaks. The relevant code could use some cleanup but I opted to avoid the significant churn in this change. I'll tackle that separately. This change is the final piece needed to make _datetime support multiple interpreters. I've updated the module slot accordingly.
* gh-117398: Add datetime Module State (gh-119810)Eric Snow2024-06-034-0/+6
| | | | | | | | | | | | I was able to make use of the existing datetime_state struct, but there was one tricky thing I had to sort out. We mostly aren't converting to heap types, so we can't use things like PyType_GetModuleByDef() to look up the module state. The solution I came up with is somewhat novel, but I consider it straightforward. Also, it shouldn't have much impact on performance. In summary, this main changes here are: * I've added some macros to help hide how various objects relate to module state * as a solution to the module state lookup problem, I've stored the last loaded module on the current interpreter's internal dict (actually a weakref) * if the static type method is used after the module has been deleted, it is reloaded * to avoid extra work when loading the module, we directly copy the objects (new refs only) from the old module state into the new state if the old module hasn't been deleted yet * during module init we set various objects on the static types' __dict__s; to simplify things, we only do that the first time; once those static types have a separate __dict__ per interpreter, we'll do it every time * we now clear the module state when the module is destroyed (before, we were leaking everything in _datetime_global_state)
* gh-117657: Fix race involving immortalizing objects (#119927)Sam Gross2024-06-031-9/+5
| | | | | | | | | 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.
* gh-116560: Add PyLong_GetSign() public function (#116561)Sergey B Kirpichev2024-06-031-3/+7
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-112026: Deprecate _PyDict_GetItemStringWithError() function (#119855)Victor Stinner2024-06-031-1/+2
|
* gh-117657: Fix TSAN reported race in `_PyEval_IsGILEnabled`. (#119921)Sam Gross2024-06-021-1/+2
| | | | The GIL may be disabled concurrently with this call so we need to use a relaxed atomic load.
* gh-119740: Remove deprecated trunc delegation (#119743)Mark Dickinson2024-06-024-6/+0
| | | | | | | | Remove the delegation of `int` to the `__trunc__` special method: `int` will now only delegate to `__int__` and `__index__` (in that order). `__trunc__` continues to exist, but its sole purpose is to support `math.trunc`. --------- Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-119821: Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS (#119822)Jelle Zijlstra2024-05-312-5/+0
| | | | | | | | | Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS The implementation basically copies LOAD_GLOBAL. Possibly it could be deduplicated, but that seems like it may get hairy since the two operations have different operands. This is important to fix in 3.14 for PEP 649, but it's a bug in earlier versions too, and we should backport to 3.13 and 3.12 if possible.
* gh-119799: Add missing `_Py_IncRefTotal` to `_Py_NewRefWithLock` (#119800)Sam Gross2024-05-311-0/+3
| | | | The free-threaded refleak builds were reporting negative refcount deltas in some tests because of a missing `_Py_NewRefWithLock`.
* gh-119853: Add Include/refcount.h file (#119854)Victor Stinner2024-05-313-482/+501
|
* gh-119744: move a few functions from compile.c to flowgraph.c (#119745)Irit Katriel2024-05-302-6/+7
|
* gh-119336: Restore removed _PyLong_NumBits() function (#119418)Ethan Smith2024-05-302-11/+9
| | | It is used by the pywin32 project.
* gh-119613: Soft deprecate Py_IS_NAN/INFINITY/FINITE (#119701)Sergey B Kirpichev2024-05-291-0/+3
| | | | | Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-97588: Align ctypes struct layout to GCC/MSVC (GH-97702)Matthias Görgens2024-05-294-0/+6
| | | | | | | Structure layout, and especially bitfields, sometimes resulted in clearly wrong behaviour like overlapping fields. This fixes Co-authored-by: Gregory P. Smith <gps@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-119689: generate stack effect metadata for pseudo instructions (#119691)Irit Katriel2024-05-291-0/+32
|
* GH-119258: Handle STORE_ATTR_WITH_HINT in tier two (GH-119481)Brandt Bucher2024-05-284-17/+22
|
* GH-119476: Split _CHECK_FUNCTION_VERSION out of _CHECK_FUNCTION_EXACT_ARGS ↵Brandt Bucher2024-05-281-3/+3
| | | | (GH-119510)
* gh-119676: remove several pseudo instructions which are use only in codegen ↵Irit Katriel2024-05-282-33/+13
| | | | (#119677)