From dcc54215ac1eb4b6fab2a9ffe1abcdf3ac4bb77e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 5 Oct 2020 12:32:00 +0300 Subject: [PATCH] bpo-41936. Remove macros Py_ALLOW_RECURSION/Py_END_ALLOW_RECURSION (GH-22552) --- Doc/whatsnew/3.10.rst | 5 +++++ Include/ceval.h | 8 -------- Include/cpython/pystate.h | 2 -- .../next/C API/2020-10-05-01-25-23.bpo-41936.1gb5ra.rst | 3 +++ Python/ceval.c | 3 --- Python/pystate.c | 1 - 6 files changed, 8 insertions(+), 14 deletions(-) create mode 100644 Misc/NEWS.d/next/C API/2020-10-05-01-25-23.bpo-41936.1gb5ra.rst diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 9c3a0287d55..1ea5aeac8a3 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -365,3 +365,8 @@ Removed * 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`.) + +* Removed undocumented macros ``Py_ALLOW_RECURSION`` and + ``Py_END_ALLOW_RECURSION`` and the ``recursion_critical`` field of the + :c:type:`PyInterpreterState` structure. + (Contributed by Serhiy Storchaka in :issue:`41936`.) diff --git a/Include/ceval.h b/Include/ceval.h index 0f372e2044a..0f687666e2b 100644 --- a/Include/ceval.h +++ b/Include/ceval.h @@ -67,14 +67,6 @@ PyAPI_FUNC(int) Py_GetRecursionLimit(void); PyAPI_FUNC(int) Py_EnterRecursiveCall(const char *where); PyAPI_FUNC(void) Py_LeaveRecursiveCall(void); -#define Py_ALLOW_RECURSION \ - do { unsigned char _old = PyThreadState_GET()->recursion_critical;\ - PyThreadState_GET()->recursion_critical = 1; - -#define Py_END_ALLOW_RECURSION \ - PyThreadState_GET()->recursion_critical = _old; \ - } while(0); - PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *); PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *); diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h index 42a7fc16306..5d5e4e33197 100644 --- a/Include/cpython/pystate.h +++ b/Include/cpython/pystate.h @@ -56,8 +56,6 @@ struct _ts { int recursion_depth; char overflowed; /* The stack has overflowed. Allow 50 more calls to handle the runtime error. */ - char recursion_critical; /* The current calls must not cause - a stack overflow. */ int stackcheck_counter; /* 'tracing' keeps track of the execution depth when tracing/profiling. diff --git a/Misc/NEWS.d/next/C API/2020-10-05-01-25-23.bpo-41936.1gb5ra.rst b/Misc/NEWS.d/next/C API/2020-10-05-01-25-23.bpo-41936.1gb5ra.rst new file mode 100644 index 00000000000..64613533086 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2020-10-05-01-25-23.bpo-41936.1gb5ra.rst @@ -0,0 +1,3 @@ +Removed undocumented macros ``Py_ALLOW_RECURSION`` and +``Py_END_ALLOW_RECURSION`` and the ``recursion_critical`` field of the +:c:type:`PyInterpreterState` structure. diff --git a/Python/ceval.c b/Python/ceval.c index 7c6cf83bc9a..500c588e3c2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -814,9 +814,6 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) return -1; } #endif - if (tstate->recursion_critical) - /* Somebody asked that we don't check for recursion. */ - return 0; if (tstate->overflowed) { if (tstate->recursion_depth > recursion_limit + 50) { /* Overflowing while handling an overflow. Give up. */ diff --git a/Python/pystate.c b/Python/pystate.c index f6d1956e9dc..eb24f2b8006 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -581,7 +581,6 @@ new_threadstate(PyInterpreterState *interp, int init) tstate->frame = NULL; tstate->recursion_depth = 0; tstate->overflowed = 0; - tstate->recursion_critical = 0; tstate->stackcheck_counter = 0; tstate->tracing = 0; tstate->use_tracing = 0;