Skip to content

Commit dcc5421

Browse files
bpo-41936. Remove macros Py_ALLOW_RECURSION/Py_END_ALLOW_RECURSION (pythonGH-22552)
1 parent 9a76426 commit dcc5421

File tree

6 files changed

+8
-14
lines changed

6 files changed

+8
-14
lines changed

Doc/whatsnew/3.10.rst

+5
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,8 @@ Removed
365365
* Removed ``_Py_CheckRecursionLimit`` variable: it has been replaced by
366366
``ceval.recursion_limit`` of the :c:type:`PyInterpreterState` structure.
367367
(Contributed by Victor Stinner in :issue:`41834`.)
368+
369+
* Removed undocumented macros ``Py_ALLOW_RECURSION`` and
370+
``Py_END_ALLOW_RECURSION`` and the ``recursion_critical`` field of the
371+
:c:type:`PyInterpreterState` structure.
372+
(Contributed by Serhiy Storchaka in :issue:`41936`.)

Include/ceval.h

-8
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ PyAPI_FUNC(int) Py_GetRecursionLimit(void);
6767
PyAPI_FUNC(int) Py_EnterRecursiveCall(const char *where);
6868
PyAPI_FUNC(void) Py_LeaveRecursiveCall(void);
6969

70-
#define Py_ALLOW_RECURSION \
71-
do { unsigned char _old = PyThreadState_GET()->recursion_critical;\
72-
PyThreadState_GET()->recursion_critical = 1;
73-
74-
#define Py_END_ALLOW_RECURSION \
75-
PyThreadState_GET()->recursion_critical = _old; \
76-
} while(0);
77-
7870
PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
7971
PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
8072

Include/cpython/pystate.h

-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ struct _ts {
5656
int recursion_depth;
5757
char overflowed; /* The stack has overflowed. Allow 50 more calls
5858
to handle the runtime error. */
59-
char recursion_critical; /* The current calls must not cause
60-
a stack overflow. */
6159
int stackcheck_counter;
6260

6361
/* 'tracing' keeps track of the execution depth when tracing/profiling.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Removed undocumented macros ``Py_ALLOW_RECURSION`` and
2+
``Py_END_ALLOW_RECURSION`` and the ``recursion_critical`` field of the
3+
:c:type:`PyInterpreterState` structure.

Python/ceval.c

-3
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,6 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where)
814814
return -1;
815815
}
816816
#endif
817-
if (tstate->recursion_critical)
818-
/* Somebody asked that we don't check for recursion. */
819-
return 0;
820817
if (tstate->overflowed) {
821818
if (tstate->recursion_depth > recursion_limit + 50) {
822819
/* Overflowing while handling an overflow. Give up. */

Python/pystate.c

-1
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ new_threadstate(PyInterpreterState *interp, int init)
581581
tstate->frame = NULL;
582582
tstate->recursion_depth = 0;
583583
tstate->overflowed = 0;
584-
tstate->recursion_critical = 0;
585584
tstate->stackcheck_counter = 0;
586585
tstate->tracing = 0;
587586
tstate->use_tracing = 0;

0 commit comments

Comments
 (0)