diff options
author | Victor Stinner <vstinner@python.org> | 2020-09-23 12:04:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-23 12:04:57 (GMT) |
commit | 19c3ac92bf73f1902cff846988552fd7bb8a8621 (patch) | |
tree | 67d42b5fe67c9c89f3ef018227b7dff150f1d7b4 /Python | |
parent | ddc0dd001a4224274ba6f83568b45a1dd88c6fc6 (diff) | |
download | cpython-19c3ac92bf73f1902cff846988552fd7bb8a8621.zip cpython-19c3ac92bf73f1902cff846988552fd7bb8a8621.tar.gz cpython-19c3ac92bf73f1902cff846988552fd7bb8a8621.tar.bz2 |
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.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 3de372f..4bb4b82 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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. */ |