https://github.com/python/cpython/commit/c3ae5c9e4ad121f8ba60ffe81ca4e2a9c52dc659
commit: c3ae5c9e4ad121f8ba60ffe81ca4e2a9c52dc659
branch: main
author: Mark Shannon <[email protected]>
committer: markshannon <[email protected]>
date: 2025-01-31T12:12:24Z
summary:
GH-128563: Simplify recursion check in `_PyEval_EvalFrameDefault` (GH-129481)
Simplify recursion check in _PyEval_EvalFrameDefault
files:
M Python/ceval.c
diff --git a/Python/ceval.c b/Python/ceval.c
index 10c20faf852479..e3b87441f8088d 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -786,7 +786,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate,
_PyInterpreterFrame *frame, int
_PyInterpreterFrame entry_frame;
-
+ if (_Py_EnterRecursiveCallTstate(tstate, "")) {
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
+ _PyEval_FrameClearAndPop(tstate, frame);
+ return NULL;
+ }
#if defined(Py_DEBUG) && !defined(Py_STACKREF_DEBUG)
/* Set these to invalid but identifiable values for debugging. */
@@ -811,11 +815,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate,
_PyInterpreterFrame *frame, int
tstate->current_frame = frame;
tstate->c_recursion_remaining -= (PY_EVAL_C_STACK_UNITS - 1);
- if (_Py_EnterRecursiveCallTstate(tstate, "")) {
- tstate->c_recursion_remaining--;
- tstate->py_recursion_remaining--;
- goto exit_unwind;
- }
/* support for generator.throw() */
if (throwflag) {
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]