]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
simplify code to pop exception in frame_setlineno (#111702)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Mon, 6 Nov 2023 15:45:33 +0000 (15:45 +0000)
committerGitHub <noreply@github.com>
Mon, 6 Nov 2023 15:45:33 +0000 (15:45 +0000)
Objects/frameobject.c

index 3b72651a1c0f7415306eb99d949c0a43c432f368..3a10f622ccc6c79137f267a55823f6b6796a7fb2 100644 (file)
@@ -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);