Skip to content

Commit

Permalink
simplify code to pop exception in frame_setlineno (python#111702)
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel authored and Glyphack committed Jan 27, 2024
1 parent 84be68a commit 9f07928
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,13 +808,10 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
while (start_stack > best_stack) {
if (top_of_stack(start_stack) == Except) {
/* Pop exception stack as well as the evaluation stack */
PyThreadState *tstate = _PyThreadState_GET();
_PyErr_StackItem *exc_info = tstate->exc_info;
PyObject *value = exc_info->exc_value;
PyObject *exc = _PyFrame_StackPop(f->f_frame);
assert(PyExceptionInstance_Check(exc) || exc == Py_None);
exc_info->exc_value = exc;
Py_XDECREF(value);
PyThreadState *tstate = _PyThreadState_GET();
Py_XSETREF(tstate->exc_info->exc_value, exc);
}
else {
PyObject *v = _PyFrame_StackPop(f->f_frame);
Expand Down

0 comments on commit 9f07928

Please sign in to comment.