simplify code to pop exception in frame_setlineno (#111702)

This commit is contained in:
Irit Katriel 2023-11-06 15:45:33 +00:00 committed by GitHub
parent 5e5762a2b8
commit c5063fd62a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -808,13 +808,10 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
while (start_stack > best_stack) { while (start_stack > best_stack) {
if (top_of_stack(start_stack) == Except) { if (top_of_stack(start_stack) == Except) {
/* Pop exception stack as well as the evaluation stack */ /* 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); PyObject *exc = _PyFrame_StackPop(f->f_frame);
assert(PyExceptionInstance_Check(exc) || exc == Py_None); assert(PyExceptionInstance_Check(exc) || exc == Py_None);
exc_info->exc_value = exc; PyThreadState *tstate = _PyThreadState_GET();
Py_XDECREF(value); Py_XSETREF(tstate->exc_info->exc_value, exc);
} }
else { else {
PyObject *v = _PyFrame_StackPop(f->f_frame); PyObject *v = _PyFrame_StackPop(f->f_frame);