Skip to content

bpo-41936. Remove macros Py_ALLOW_RECURSION/Py_END_ALLOW_RECURSION #22552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,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`.)
8 changes: 0 additions & 8 deletions Include/ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down
2 changes: 0 additions & 2 deletions Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 0 additions & 3 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
1 change: 0 additions & 1 deletion Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down