Skip to content

Commit 38792f2

Browse files
committed
Add FRAME_UNWINDING to mark unwinding state.
1 parent a22412c commit 38792f2

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Include/cpython/frameobject.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ enum _framestate {
1212
FRAME_SUSPENDED = -1,
1313
FRAME_EXECUTING = 0,
1414
FRAME_RETURNED = 1,
15-
FRAME_RAISED = 2,
16-
FRAME_CLEARED = 3
15+
FRAME_UNWINDING = 2,
16+
FRAME_RAISED = 3,
17+
FRAME_CLEARED = 4
1718
};
1819

1920
typedef signed char PyFrameState;

Objects/frameobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
369369
"can't jump from the 'call' trace event of a new frame");
370370
return -1;
371371
case FRAME_RETURNED:
372+
case FRAME_UNWINDING:
372373
case FRAME_RAISED:
373374
case FRAME_CLEARED:
374375
PyErr_SetString(PyExc_ValueError,

Python/ceval.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3769,14 +3769,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
37693769
PyTraceBack_Here(f);
37703770

37713771
if (tstate->c_tracefunc != NULL) {
3772-
/* Temporarily set frame state to RAISED for benefit of frame.setlineno */
3772+
/* Make sure state is set to FRAME_EXECUTING for tracing */
37733773
assert(f->f_state == FRAME_EXECUTING);
3774-
f->f_state = FRAME_RAISED;
3774+
f->f_state = FRAME_UNWINDING;
37753775
call_exc_trace(tstate->c_tracefunc, tstate->c_traceobj,
37763776
tstate, f);
3777-
f->f_state = FRAME_EXECUTING;
37783777
}
37793778
exception_unwind:
3779+
f->f_state = FRAME_UNWINDING;
37803780
/* Unwind stacks if an exception occurred */
37813781
while (f->f_iblock > 0) {
37823782
/* Pop the current block. */
@@ -3835,6 +3835,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
38353835
}
38363836
}
38373837
/* Resume normal execution */
3838+
f->f_state = FRAME_EXECUTING;
38383839
goto main_loop;
38393840
}
38403841
} /* unwind stack */

0 commit comments

Comments
 (0)