summaryrefslogtreecommitdiffstats
path: root/Include/cpython
Commit message (Collapse)AuthorAgeFilesLines
* [3.12] gh-116767: fix crash on 'async with' with many context managers ↵Irit Katriel2024-05-011-1/+1
| | | | | | | | | | | | (GH-118348) (#118477) gh-116767: fix crash on 'async with' with many context managers (GH-118348) Account for `add_stopiteration_handler` pushing a block for `async with`. To allow generator functions that previously almost hit the `CO_MAXBLOCKS` limit by nesting non-async blocks, the limit is increased by 1. This increase allows one more block in non-generator functions. (cherry picked from commit c1bf4874c1e9db2beda1d62c8c241229783c789b)
* [3.12] gh-118207: Rename the COMMON_FIELDS macro in funcobject.h and undef ↵Miss Islington (bot)2024-04-261-3/+5
| | | | | | | | it after use (GH-118208) (#118269) gh-118207: Rename the COMMON_FIELDS macro in funcobject.h and undef it after use (GH-118208) (cherry picked from commit 796b3fb28057948ea5b98f7eb0c0f3af6a1e276e) Co-authored-by: Itamar Oren <itamarost@gmail.com>
* [3.12] gh-116869: Make C API compatible with ISO C90 (GH-116950) (#117011)Miss Islington (bot)2024-03-191-1/+2
| | | | | | | | | gh-116869: Make C API compatible with ISO C90 (GH-116950) Make the C API compatible with -Werror=declaration-after-statement compiler flag again. (cherry picked from commit a9c304cf020e2fa3ae78fd88359dfc808c9dd639) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.12] chore: fix typos (#116345) (#116370)Terry Jan Reedy2024-03-051-1/+1
| | | | Co-authored-by: cui fliter <imcusg@gmail.com> (cherry picked from commit e7ba6e9dbe5433b4a0bcb0658da6a68197c28630)
* [3.12] GH-112215: Backport C recursion changes (GH-115083)Mark Shannon2024-02-131-4/+16
|
* [3.12] gh-106931: Intern Statically Allocated Strings Globally (gh-107272) ↵Eric Snow2023-11-271-1/+3
| | | | | | | | | (gh-110713) We tried this before with a dict and for all interned strings. That ran into problems due to interpreter isolation. However, exclusively using a per-interpreter cache caused some inconsistency that can eliminate the benefit of interning. Here we circle back to using a global cache, but only for statically allocated strings. We also use a more-basic _Py_hashtable_t for that global cache instead of a dict. Ideally we would only have the global cache, but the optional isolation of each interpreter's allocator means that a non-static string object must not outlive its interpreter. Thus we would have to store a copy of each such interned string in the global cache, tied to the main interpreter. (cherry-picked from commit b72947a8d26915156323ccfd04d273199ecb870c)
* [3.12] GH-108390: Prevent non-local events being set with ↵Mark Shannon2023-09-051-6/+13
| | | | | | | | | | | `sys.monitoring.set_local_events()` (GH-108420) (#108899) * GH-108390: Prevent non-local events being set with `sys.monitoring.set_local_events()` (GH-108420) * Restore generated objects * Restore size of monitoring arrays in code object for 3.12 ABI compatibility. * Update ABI file
* [3.12] gh-91051: fix segfault when using all 8 type watchers (GH-107853) ↵Miss Islington (bot)2023-08-161-1/+1
| | | | | | | | (#107876) * gh-91051: fix segfault when using all 8 type watchers (GH-107853) (cherry picked from commit 66e4edd7346b1cd65ddff6da890a0d725e325116) Co-authored-by: Carl Meyer <carl@oddbird.net>
* [3.12] GH-107263: Increase C stack limit for most functions, except ↵Miss Islington (bot)2023-08-041-1/+2
| | | | | | | | | | `_PyEval_EvalFrameDefault()` (GH-107535) (#107618) GH-107263: Increase C stack limit for most functions, except `_PyEval_EvalFrameDefault()` (GH-107535) * Set C recursion limit to 1500, set cost of eval loop to 2 frames, and compiler mutliply to 2. (cherry picked from commit fa45958450aa3489607daf9855ca0474a2a20878) Co-authored-by: Mark Shannon <mark@hotpy.org>
* [3.12] GH-106897: Add `RERAISE` event to `sys.monitoring`. (GH-107291) ↵Mark Shannon2023-07-281-2/+2
| | | | | | (GH-107346) * Ensures that exception handling events are balanced. Each [re]raise event has a matching unwind/handled event.
* [3.12] gh-101524: Only Use Public C-API in the _xxsubinterpreters Module ↵Miss Islington (bot)2023-07-271-0/+11
| | | | | | | | (gh-105258) (gh-107303) The _xxsubinterpreters module was meant to only use public API. Some internal C-API usage snuck in over the last few years (e.g. gh-28969). This fixes that. (cherry picked from commit e6373c0d8b59512aa7f0dea7f3fb162b6ed10fa4) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* [3.12] gh-98608: Move PyInterpreterConfig to pylifecycle.h (GH-107191) (#107198)Miss Islington (bot)2023-07-242-39/+39
| | | | | | | | | | gh-98608: Move PyInterpreterConfig to pylifecycle.h (GH-107191) Move PyInterpreterConfig structure and associated macros from initconfig.h to pylifecycle.h: it's not related to the Python Initialization Configuration. (cherry picked from commit e717b47ed8ae7017f0bfb835fe673aa836e8fcca) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.12] GH-96803: Move PyUnstable_InterpreterFrame_GetCode() to Python.h ↵Miss Islington (bot)2023-07-242-17/+17
| | | | | | | | | | | | (GH-107188) (#107195) GH-96803: Move PyUnstable_InterpreterFrame_GetCode() to Python.h (GH-107188) Declare the following 3 PyUnstable functions in Include/cpython/pyframe.h rather than Include/cpython/frameobject.h, so they are now provided by the standard "GH-include <Python.h>". (cherry picked from commit 837fa5c0cd92e70f625377c9ffb7ac31a23d7d63) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.12] GH-103082: Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS ↵Victor Stinner2023-07-221-3/+3
| | | | | | | | | | | | (#107069) (#107075) GH-103082: Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS (#107069) Rename private C API constants: * Rename PY_MONITORING_UNGROUPED_EVENTS to _PY_MONITORING_UNGROUPED_EVENTS * Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS (cherry picked from commit 0927a2b25c059988e237108605ed8ab0c5459c53)
* [3.12] gh-86493: Fix possible leaks in some modules initialization ↵Serhiy Storchaka2023-07-181-0/+1
| | | | | | (GH-106768) (GH-106855) Fix _ssl, _stat, _testinternalcapi, _threadmodule, cmath, math, posix, time. (cherry picked from commit 3e65baee72131b49f4ce8ca2da568a6f2001ce93)
* [3.12] gh-105227: Add PyType_GetDict() (GH-105747) (#106600)Miss Islington (bot)2023-07-101-0/+1
| | | | | | | | | | gh-105227: Add PyType_GetDict() (GH-105747) This compensates for static builtin types having `tp_dict` set to `NULL`. (cherry picked from commit a840806d338805fe74a9de01081d30da7605a29f) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* [3.12] gh-104812: Run Pending Calls in any Thread (gh-104813) (gh-105752)Eric Snow2023-06-141-0/+2
| | | | For a while now, pending calls only run in the main thread (in the main interpreter). This PR changes things to allow any thread run a pending call, unless the pending call was explicitly added for the main thread to run. (cherry picked from commit 757b402)
* [3.12] gh-105603: Change the PyInterpreterConfig.own gil Field (gh-105620) ↵Miss Islington (bot)2023-06-131-3/+7
| | | | | | | | (gh-105731) We are changing it to be more flexible that a strict bool can be for possible future expanded used cases. (cherry picked from commit b97e14a806477af4225777d215ac38c0d9b845f0) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* [3.12] gh-105071: add PyUnstable_Exc_PrepReraiseStar to expose except* ↵Irit Katriel2023-05-301-0/+4
| | | | | implementation in the unstable API (GH-105072) (#105095) (cherry picked from commit b7aadb4583b040ddc8564896b91f4e5e571c82d6)
* [3.12] GH-101291: Avoid using macros with casts in low-level long API. ↵Miss Islington (bot)2023-05-231-2/+3
| | | | | | | (GH-104742) (#104759) (cherry picked from commit e295d8605699ad3d8ec46c8d55a5e47da05b20c6) Co-authored-by: Mark Shannon <mark@hotpy.org>
* GH-101291: Add low level, unstable API for pylong (GH-101685)Mark Shannon2023-05-212-0/+31
| | | Co-authored-by: Petr Viktorin <encukou@gmail.com>
* GH-96803: Document and test new unstable internal frame API functions ↵Mark Shannon2023-05-181-1/+1
| | | | | | (GH-104211) Weaken contract of PyUnstable_InterpreterFrame_GetCode to return PyObject*.
* gh-103763: Implement PEP 695 (#103764)Jelle Zijlstra2023-05-161-0/+1
| | | | | | | | | | | | | | This implements PEP 695, Type Parameter Syntax. It adds support for: - Generic functions (def func[T](): ...) - Generic classes (class X[T](): ...) - Type aliases (type X = ...) - New scoping when the new syntax is used within a class body - Compiler and interpreter changes to support the new syntax and scoping rules Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Eric Traut <eric@traut.com> Co-authored-by: Larry Hastings <larry@hastings.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-104341: Adjust tstate_must_exit() to Respect Interpreter Finalization ↵Eric Snow2023-05-151-0/+1
| | | | | (gh-104437) With the move to a per-interpreter GIL, this check slipped through the cracks.
* GH-102181: Improve specialization stats for SEND (GH-102182)penguin_wwy2023-05-101-0/+2
|
* gh-104223: Fix issues with inheriting from buffer classes (#104227)Jelle Zijlstra2023-05-081-0/+1
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-99113: Add PyInterpreterConfig.own_gil (gh-104204)Eric Snow2023-05-051-0/+3
| | | | | We also add PyInterpreterState.ceval.own_gil to record if the interpreter actually has its own GIL. Note that for now we don't actually respect own_gil; all interpreters still share the one GIL. However, PyInterpreterState.ceval.own_gil does reflect PyInterpreterConfig.own_gil. That lie is a temporary one that we will fix when the GIL really becomes per-interpreter.
* GH-96803: Add three C-API functions to make _PyInterpreterFrame less opaque ↵Mark Shannon2023-05-051-0/+17
| | | | for users of PEP 523. (GH-96849)
* gh-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511)Petr Viktorin2023-05-041-0/+1
| | | | Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-104109: Expose Py_NewInterpreterFromConfig() in the Public C-API (gh-104110)Eric Snow2023-05-032-3/+3
| | | | | We also expose PyInterpreterConfig. This is part of the PEP 684 (per-interpreter GIL) implementation. We will add docs as soon as we can. FYI, I'm adding the new config field for per-interpreter GIL in gh-99114.
* gh-103743: Add PyUnstable_Object_GC_NewWithExtraData (GH-103744)Jurica Bradarić2023-05-021-0/+3
| | | | Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-101659: Isolate "obmalloc" State to Each Interpreter (gh-101660)Eric Snow2023-04-242-0/+8
| | | | | | | | | | | | | | This is strictly about moving the "obmalloc" runtime state from `_PyRuntimeState` to `PyInterpreterState`. Doing so improves isolation between interpreters, specifically most of the memory (incl. objects) allocated for each interpreter's use. This is important for a per-interpreter GIL, but such isolation is valuable even without it. FWIW, a per-interpreter obmalloc is the proverbial canary-in-the-coalmine when it comes to the isolation of objects between interpreters. Any object that leaks (unintentionally) to another interpreter is highly likely to cause a crash (on debug builds at least). That's a useful thing to know, relative to interpreter isolation.
* gh-103091: Add PyUnstable_Type_AssignVersionTag (#103095)Brett Simmers2023-04-241-0/+7
|
* gh-84436: Implement Immortal Objects (gh-19474)Eddie Elizondo2023-04-221-4/+13
| | | | | | | | | This is the implementation of PEP683 Motivation: The PR introduces the ability to immortalize instances in CPython which bypasses reference counting. Tagging objects as immortal allows up to skip certain operations when we know that the object will be around for the entire execution of the runtime. Note that this by itself will bring a performance regression to the runtime due to the extra reference count checks. However, this brings the ability of having truly immutable objects that are useful in other contexts such as immutable data sharing between sub-interpreters.
* GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython ↵Mark Shannon2023-04-122-12/+44
| | | | | | | | | | (GH-103083) * The majority of the monitoring code is in instrumentation.c * The new instrumentation bytecodes are in bytecodes.c * legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
* gh-101659: Add _Py_AtExit() (gh-103298)Eric Snow2023-04-061-0/+4
| | | | | The function is like Py_AtExit() but for a single interpreter. This is a companion to the atexit module's register() function, taking a C callback instead of a Python one. We also update the _xxinterpchannels module to use _Py_AtExit(), which is the motivating case. (This is inspired by pain points felt while working on gh-101660.)
* gh-102192: deprecate _PyErr_ChainExceptions (#102935)Irit Katriel2023-04-011-1/+1
|
* GH-89987: Shrink the BINARY_SUBSCR caches (GH-103022)Brandt Bucher2023-03-291-0/+11
|
* GH-101291: Rearrange the size bits in PyLongObject (GH-102464)Mark Shannon2023-03-221-1/+5
| | | | | | | | | | * Eliminate all remaining uses of Py_SIZE and Py_SET_SIZE on PyLongObject, adding asserts. * Change layout of size/sign bits in longobject to support future addition of immortal ints and tagged medium ints. * Add functions to hide some internals of long object, and for setting sign and digit count. * Replace uses of IS_MEDIUM_VALUE macro with _PyLong_IsCompact().
* gh-102406: replace exception chaining by PEP-678 notes in codecs (#102407)Irit Katriel2023-03-211-18/+0
|
* gh-102304: Move the Total Refcount to PyInterpreterState (gh-102545)Eric Snow2023-03-211-0/+1
| | | | | Moving it valuable with a per-interpreter GIL. However, it is also useful without one, since it allows us to identify refleaks within a single interpreter or where references are escaping an interpreter. This becomes more important as we move the obmalloc state to PyInterpreterState. https://github.com/python/cpython/issues/102304
* gh-98608: Stop Treating All Errors from _Py_NewInterpreterFromConfig() as ↵Eric Snow2023-03-212-2/+4
| | | | | | | Fatal (gh-102657) Prior to this change, errors in _Py_NewInterpreterFromConfig() were always fatal. Instead, callers should be able to handle such errors and keep going. That's what this change supports. (This was an oversight in the original implementation of _Py_NewInterpreterFromConfig().) Note that the existing [fatal] behavior of the public Py_NewInterpreter() is preserved. https://github.com/python/cpython/issues/98608
* gh-102304: Move _Py_RefTotal to _PyRuntimeState (gh-102543)Eric Snow2023-03-201-1/+4
| | | | | | | The essentially eliminates the global variable, with the associated benefits. This is also a precursor to isolating this bit of state to PyInterpreterState. Folks that currently read _Py_RefTotal directly would have to start using _Py_GetGlobalRefTotal() instead. https://github.com/python/cpython/issues/102304
* gh-102594: PyErr_SetObject adds note to exception raised on normalization ↵Irit Katriel2023-03-161-0/+4
| | | | error (#102675)
* gh-100227: Isolate the Import State to Each Interpreter (gh-101941)Eric Snow2023-03-091-2/+2
| | | | | | | | | | | | Specific changes: * move the import lock to PyInterpreterState * move the "find_and_load" diagnostic state to PyInterpreterState Note that the import lock exists to keep multiple imports of the same module in the same interpreter (but in different threads) from stomping on each other. Independently, we use a distinct global lock to protect globally shared import state, especially related to loaded extension modules. For now we can rely on the GIL as that lock but with a per-interpreter GIL we'll need a new global lock. The remaining state in _PyRuntimeState.imports will (probably) continue being global. https://github.com/python/cpython/issues/100227
* gh-102304: Consolidate Direct Usage of _Py_RefTotal (gh-102514)Eric Snow2023-03-081-0/+1
| | | | | This simplifies further changes to _Py_RefTotal (e.g. make it atomic or move it to PyInterpreterState). https://github.com/python/cpython/issues/102304
* gh-102381: don't call watcher callback with dead object (#102382)Carl Meyer2023-03-083-20/+30
| | | Co-authored-by: T. Wouters <thomas@python.org>
* gh-101101: Unstable C API tier (PEP 689) (GH-101102)Petr Viktorin2023-02-282-9/+45
|
* GH-100719: Remove redundant `gi_code` field from generator object. (GH-100749)Mark Shannon2023-02-231-3/+2
|
* gh-101907: Stop using `_Py_OPCODE` and `_Py_OPARG` macros (GH-101912)Steve Dower2023-02-201-7/+21
| | | | | | * gh-101907: Removes use of non-standard C++ extension from Include/cpython/code.h * Make cases_generator correct on Windows