8000 GH-128563: Simplify recursion check in `_PyEval_EvalFrameDefault` (GH… · python/cpython@c3ae5c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit c3ae5c9

Browse files
authored
GH-128563: Simplify recursion check in _PyEval_EvalFrameDefault (GH-129481)
Simplify recursion check in _PyEval_EvalFrameDefault
1 parent 31c82c2 commit c3ae5c9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Python/ceval.c

Lines changed: 5 additions & 6 deletions

Original file line numberDiff line numberDiff line change
@@ -786,7 +786,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
786786

787787
_PyInterpreterFrame entry_frame;
788788
789-
789+
if (_Py_EnterRecursiveCallTstate(tstate, "")) {
790+
assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
791+
_PyEval_FrameClearAndPop(tstate, frame);
792+
return NULL;
793+
}
790794

791795
#if defined(Py_DEBUG) && !defined(Py_STACKREF_DEBUG)
792796
/* Set these to invalid but identifiable values for debugging. */
@@ -811,11 +815,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
811815
tstate->current_frame = frame;
812816

813817
tstate->c_recursion_remaining -= (PY_EVAL_C_STACK_UNITS - 1);
814-
if (_Py_EnterRecursiveCallTstate(tstate, "")) {
815-
tstate->c_recursion_remaining--;
816-
tstate->py_recursion_remaining--;
817-
goto exit_unwind;
818-
}
819818

820819
/* support for generator.throw() */
821820
if (throwflag) {

0 commit comments

Comments
 (0)
0