mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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
7 changed files with 10 additions and 18 deletions
|
@ -741,15 +741,12 @@ Py_MakePendingCalls(void)
|
|||
/* The interpreter's recursion limit */
|
||||
|
||||
#ifndef Py_DEFAULT_RECURSION_LIMIT
|
||||
#define Py_DEFAULT_RECURSION_LIMIT 1000
|
||||
# define Py_DEFAULT_RECURSION_LIMIT 1000
|
||||
#endif
|
||||
|
||||
int _Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT;
|
||||
|
||||
void
|
||||
_PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
|
||||
{
|
||||
_Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT;
|
||||
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
||||
_gil_initialize(&ceval->gil);
|
||||
#endif
|
||||
|
@ -797,14 +794,11 @@ Py_SetRecursionLimit(int new_limit)
|
|||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
tstate->interp->ceval.recursion_limit = new_limit;
|
||||
if (_Py_IsMainInterpreter(tstate)) {
|
||||
_Py_CheckRecursionLimit = new_limit;
|
||||
}
|
||||
}
|
||||
|
||||
/* The function _Py_EnterRecursiveCall() only calls _Py_CheckRecursiveCall()
|
||||
if the recursion_depth reaches _Py_CheckRecursionLimit.
|
||||
If USE_STACKCHECK, the macro decrements _Py_CheckRecursionLimit
|
||||
if the recursion_depth reaches recursion_limit.
|
||||
If USE_STACKCHECK, the macro decrements recursion_limit
|
||||
to guarantee that _Py_CheckRecursiveCall() is regularly called.
|
||||
Without USE_STACKCHECK, there is no need for this. */
|
||||
int
|
||||
|
@ -819,10 +813,6 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where)
|
|||
_PyErr_SetString(tstate, PyExc_MemoryError, "Stack overflow");
|
||||
return -1;
|
||||
}
|
||||
if (_Py_IsMainInterpreter(tstate)) {
|
||||
/* Needed for ABI backwards-compatibility (see bpo-31857) */
|
||||
_Py_CheckRecursionLimit = recursion_limit;
|
||||
}
|
||||
#endif
|
||||
if (tstate->recursion_critical)
|
||||
/* Somebody asked that we don't check for recursion. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue