| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
(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)
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Co-authored-by: cui fliter <imcusg@gmail.com>
(cherry picked from commit e7ba6e9dbe5433b4a0bcb0658da6a68197c28630)
|
| |
|
|
|
|
|
|
|
|
|
| |
(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)
|
|
|
|
|
|
|
|
|
|
|
| |
`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
|
|
|
|
|
|
|
|
| |
(#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>
|
|
|
|
|
|
|
|
|
|
| |
`_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>
|
|
|
|
|
|
| |
(GH-107346)
* Ensures that exception handling events are balanced. Each [re]raise event has a matching unwind/handled event.
|
|
|
|
|
|
|
|
| |
(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>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
| |
(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>
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#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)
|
|
|
|
|
|
| |
(GH-106768) (GH-106855)
Fix _ssl, _stat, _testinternalcapi, _threadmodule, cmath, math, posix, time.
(cherry picked from commit 3e65baee72131b49f4ce8ca2da568a6f2001ce93)
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
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)
|
|
|
|
|
|
|
|
| |
(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>
|
|
|
|
|
| |
implementation in the unstable API (GH-105072) (#105095)
(cherry picked from commit b7aadb4583b040ddc8564896b91f4e5e571c82d6)
|
|
|
|
|
|
|
| |
(GH-104742) (#104759)
(cherry picked from commit e295d8605699ad3d8ec46c8d55a5e47da05b20c6)
Co-authored-by: Mark Shannon <mark@hotpy.org>
|
|
|
| |
Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
|
|
|
|
|
| |
(GH-104211)
Weaken contract of PyUnstable_InterpreterFrame_GetCode to return PyObject*.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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-104437)
With the move to a per-interpreter GIL, this check slipped through the cracks.
|
| |
|
|
|
| |
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
|
|
|
|
|
| |
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.
|
|
|
|
| |
for users of PEP 523. (GH-96849)
|
|
|
|
| |
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
|
|
|
|
|
| |
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.
|
|
|
|
| |
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
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-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
|
|
|
|
|
| |
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.)
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
* 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().
|
| |
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
error (#102675)
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
| |
This simplifies further changes to _Py_RefTotal (e.g. make it atomic or move it to PyInterpreterState).
https://github.com/python/cpython/issues/102304
|
|
|
| |
Co-authored-by: T. Wouters <thomas@python.org>
|
| |
|
| |
|
|
|
|
|
|
| |
* gh-101907: Removes use of non-standard C++ extension from Include/cpython/code.h
* Make cases_generator correct on Windows
|