]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41936. Remove macros Py_ALLOW_RECURSION/Py_END_ALLOW_RECURSION (GH-22552)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 5 Oct 2020 09:32:00 +0000 (12:32 +0300)
committerGitHub <noreply@github.com>
Mon, 5 Oct 2020 09:32:00 +0000 (12:32 +0300)
Doc/whatsnew/3.10.rst
Include/ceval.h
Include/cpython/pystate.h
Misc/NEWS.d/next/C API/2020-10-05-01-25-23.bpo-41936.1gb5ra.rst [new file with mode: 0644]
Python/ceval.c
Python/pystate.c

index 9c3a0287d55095564b72cf7e2c73fb0a3a4b43b4..1ea5aeac8a3c62323657fbfcab5e8fdace5fdc28 100644 (file)
@@ -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`.)
index 0f372e2044a1c8ab4ba600331107b4f2dfcd2d14..0f687666e2bccf5dcaf3812c74d9df227dc868da 100644 (file)
@@ -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 *);
 
index 42a7fc163064dc8825f17cd1dfd9fdc68b4aca1a..5d5e4e331978ac1264ed7161a366c5d7f654fa7f 100644 (file)
@@ -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 (file)
index 0000000..6461353
--- /dev/null
@@ -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.
index 7c6cf83bc9ac01282a0552fca6f0a8ac5ef69383..500c588e3c2afb733380ef2983f4da6447ce58b0 100644 (file)
@@ -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. */
index f6d1956e9dce9aef35b47d45a4fea3fdd330700c..eb24f2b800607fd8381d337f01dc45c8e95b20f6 100644 (file)
@@ -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;