bpo-41834: Remove _Py_CheckRecursionLimit variable (GH-22359)
Remove the global _Py_CheckRecursionLimit variable: it has been replaced by ceval.recursion_limit of the PyInterpreterState structure. There is no need to keep the variable for the stable ABI, since Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() were not usable in Python 3.8 and older: these macros accessed PyThreadState members, whereas the PyThreadState structure is opaque in the limited C API.
This commit is contained in:
parent
ddc0dd001a
commit
19c3ac92bf
|
@ -314,3 +314,7 @@ Removed
|
||||||
* Removed ``PyUnicode_AsUnicodeCopy()``. Please use :c:func:`PyUnicode_AsUCS4Copy` or
|
* Removed ``PyUnicode_AsUnicodeCopy()``. Please use :c:func:`PyUnicode_AsUCS4Copy` or
|
||||||
:c:func:`PyUnicode_AsWideCharString`
|
:c:func:`PyUnicode_AsWideCharString`
|
||||||
(Contributed by Inada Naoki in :issue:`41103`.)
|
(Contributed by Inada Naoki in :issue:`41103`.)
|
||||||
|
|
||||||
|
* Removed ``_Py_CheckRecursionLimit`` variable: it has been replaced by
|
||||||
|
``ceval.recursion_limit`` of the :c:type:`PyInterpreterState` structure.
|
||||||
|
(Contributed by Victor Stinner in :issue:`41834`.)
|
||||||
|
|
|
@ -63,8 +63,6 @@ extern void _PyEval_ReleaseLock(PyThreadState *tstate);
|
||||||
|
|
||||||
/* --- _Py_EnterRecursiveCall() ----------------------------------------- */
|
/* --- _Py_EnterRecursiveCall() ----------------------------------------- */
|
||||||
|
|
||||||
PyAPI_DATA(int) _Py_CheckRecursionLimit;
|
|
||||||
|
|
||||||
#ifdef USE_STACKCHECK
|
#ifdef USE_STACKCHECK
|
||||||
/* With USE_STACKCHECK macro defined, trigger stack checks in
|
/* With USE_STACKCHECK macro defined, trigger stack checks in
|
||||||
_Py_CheckRecursiveCall() on every 64th call to Py_EnterRecursiveCall. */
|
_Py_CheckRecursiveCall() on every 64th call to Py_EnterRecursiveCall. */
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Remove the ``_Py_CheckRecursionLimit`` variable: it has been replaced by
|
||||||
|
``ceval.recursion_limit`` of the :c:type:`PyInterpreterState`
|
||||||
|
structure. Patch by Victor Stinner.
|
|
@ -663,7 +663,6 @@ EXPORT_FUNC(PyWeakref_NewProxy)
|
||||||
EXPORT_FUNC(PyWeakref_NewRef)
|
EXPORT_FUNC(PyWeakref_NewRef)
|
||||||
EXPORT_FUNC(PyWrapper_New)
|
EXPORT_FUNC(PyWrapper_New)
|
||||||
|
|
||||||
EXPORT_DATA(_Py_CheckRecursionLimit)
|
|
||||||
EXPORT_DATA(_Py_EllipsisObject)
|
EXPORT_DATA(_Py_EllipsisObject)
|
||||||
EXPORT_DATA(_Py_FalseStruct)
|
EXPORT_DATA(_Py_FalseStruct)
|
||||||
EXPORT_DATA(_Py_NoneStruct)
|
EXPORT_DATA(_Py_NoneStruct)
|
||||||
|
|
|
@ -741,15 +741,12 @@ Py_MakePendingCalls(void)
|
||||||
/* The interpreter's recursion limit */
|
/* The interpreter's recursion limit */
|
||||||
|
|
||||||
#ifndef Py_DEFAULT_RECURSION_LIMIT
|
#ifndef Py_DEFAULT_RECURSION_LIMIT
|
||||||
#define Py_DEFAULT_RECURSION_LIMIT 1000
|
# define Py_DEFAULT_RECURSION_LIMIT 1000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int _Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
|
_PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
|
||||||
{
|
{
|
||||||
_Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT;
|
|
||||||
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
||||||
_gil_initialize(&ceval->gil);
|
_gil_initialize(&ceval->gil);
|
||||||
#endif
|
#endif
|
||||||
|
@ -797,14 +794,11 @@ Py_SetRecursionLimit(int new_limit)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
tstate->interp->ceval.recursion_limit = new_limit;
|
tstate->interp->ceval.recursion_limit = new_limit;
|
||||||
if (_Py_IsMainInterpreter(tstate)) {
|
|
||||||
_Py_CheckRecursionLimit = new_limit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The function _Py_EnterRecursiveCall() only calls _Py_CheckRecursiveCall()
|
/* The function _Py_EnterRecursiveCall() only calls _Py_CheckRecursiveCall()
|
||||||
if the recursion_depth reaches _Py_CheckRecursionLimit.
|
if the recursion_depth reaches recursion_limit.
|
||||||
If USE_STACKCHECK, the macro decrements _Py_CheckRecursionLimit
|
If USE_STACKCHECK, the macro decrements recursion_limit
|
||||||
to guarantee that _Py_CheckRecursiveCall() is regularly called.
|
to guarantee that _Py_CheckRecursiveCall() is regularly called.
|
||||||
Without USE_STACKCHECK, there is no need for this. */
|
Without USE_STACKCHECK, there is no need for this. */
|
||||||
int
|
int
|
||||||
|
@ -819,10 +813,6 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where)
|
||||||
_PyErr_SetString(tstate, PyExc_MemoryError, "Stack overflow");
|
_PyErr_SetString(tstate, PyExc_MemoryError, "Stack overflow");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (_Py_IsMainInterpreter(tstate)) {
|
|
||||||
/* Needed for ABI backwards-compatibility (see bpo-31857) */
|
|
||||||
_Py_CheckRecursionLimit = recursion_limit;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (tstate->recursion_critical)
|
if (tstate->recursion_critical)
|
||||||
/* Somebody asked that we don't check for recursion. */
|
/* Somebody asked that we don't check for recursion. */
|
||||||
|
|
|
@ -66,7 +66,6 @@ Objects/tupleobject.c:_Py_tuple_zero_allocs Py_ssize_t _Py_
|
||||||
Objects/typeobject.c:next_version_tag static unsigned int next_version_tag
|
Objects/typeobject.c:next_version_tag static unsigned int next_version_tag
|
||||||
Python/Python-ast.c:init_types():initialized static int initialized
|
Python/Python-ast.c:init_types():initialized static int initialized
|
||||||
Python/bootstrap_hash.c:urandom_cache static struct { int fd; dev_t st_dev; ino_t st_ino; } urandom_cache
|
Python/bootstrap_hash.c:urandom_cache static struct { int fd; dev_t st_dev; ino_t st_ino; } urandom_cache
|
||||||
Python/ceval.c:_Py_CheckRecursionLimit int _Py_CheckRecursionLimit
|
|
||||||
Python/ceval.c:lltrace static int lltrace
|
Python/ceval.c:lltrace static int lltrace
|
||||||
Python/ceval.c:make_pending_calls():busy static int busy
|
Python/ceval.c:make_pending_calls():busy static int busy
|
||||||
Python/dynload_shlib.c:handles static struct { dev_t dev; ino_t ino; void *handle; } handles[128]
|
Python/dynload_shlib.c:handles static struct { dev_t dev; ino_t ino; void *handle; } handles[128]
|
||||||
|
|
|
@ -805,7 +805,6 @@ Objects/iterobject.c - PyCallIter_Type variable PyTypeObject PyCallIter_Type
|
||||||
Objects/capsule.c - PyCapsule_Type variable PyTypeObject PyCapsule_Type
|
Objects/capsule.c - PyCapsule_Type variable PyTypeObject PyCapsule_Type
|
||||||
Objects/cellobject.c - PyCell_Type variable PyTypeObject PyCell_Type
|
Objects/cellobject.c - PyCell_Type variable PyTypeObject PyCell_Type
|
||||||
Objects/methodobject.c - PyCFunction_Type variable PyTypeObject PyCFunction_Type
|
Objects/methodobject.c - PyCFunction_Type variable PyTypeObject PyCFunction_Type
|
||||||
Python/ceval.c - _Py_CheckRecursionLimit variable int _Py_CheckRecursionLimit
|
|
||||||
Objects/descrobject.c - PyClassMethodDescr_Type variable PyTypeObject PyClassMethodDescr_Type
|
Objects/descrobject.c - PyClassMethodDescr_Type variable PyTypeObject PyClassMethodDescr_Type
|
||||||
Objects/funcobject.c - PyClassMethod_Type variable PyTypeObject PyClassMethod_Type
|
Objects/funcobject.c - PyClassMethod_Type variable PyTypeObject PyClassMethod_Type
|
||||||
Objects/codeobject.c - PyCode_Type variable PyTypeObject PyCode_Type
|
Objects/codeobject.c - PyCode_Type variable PyTypeObject PyCode_Type
|
||||||
|
|
Can't render this file because it contains an unexpected character in line 140 and column 79.
|
Loading…
Reference in New Issue