]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44472: Fix ltrace functionality when exceptions are raised (GH-26822)
authorPablo Galindo <Pablogsal@gmail.com>
Mon, 21 Jun 2021 15:23:53 +0000 (16:23 +0100)
committerGitHub <noreply@github.com>
Mon, 21 Jun 2021 15:23:53 +0000 (16:23 +0100)
Misc/NEWS.d/next/Core and Builtins/2021-06-21-11-19-54.bpo-44472.Vvm1yn.rst [new file with mode: 0644]
Python/ceval.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-06-21-11-19-54.bpo-44472.Vvm1yn.rst b/Misc/NEWS.d/next/Core and Builtins/2021-06-21-11-19-54.bpo-44472.Vvm1yn.rst
new file mode 100644 (file)
index 0000000..34fa2a9
--- /dev/null
@@ -0,0 +1 @@
+Fix ltrace functionality when exceptions are raised. Patch by Pablo Galindo
index b5e3dd53c8439a451d42d22c6afdf1af22c0583c..9c11640ec6e0cdb3672c8a2aa578178769a4866d 100644 (file)
@@ -5325,11 +5325,14 @@ static int
 prtrace(PyThreadState *tstate, PyObject *v, const char *str)
 {
     printf("%s ", str);
+    PyObject *type, *value, *traceback;
+    PyErr_Fetch(&type, &value, &traceback);
     if (PyObject_Print(v, stdout, 0) != 0) {
         /* Don't know what else to do */
         _PyErr_Clear(tstate);
     }
     printf("\n");
+    PyErr_Restore(type, value, traceback);
     return 1;
 }
 #endif