[Python-checkins] bpo-44472: Fix ltrace functionality when exceptions are raised (GH-26822) (GH-26830)

pablogsal webhook-mailer at python.org
Tue Jul 13 04:43:59 EDT 2021


https://github.com/python/cpython/commit/4a0f1df9527f7d67064d33f5366476b3c93dc86c
commit: 4a0f1df9527f7d67064d33f5366476b3c93dc86c
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: pablogsal <Pablogsal at gmail.com>
date: 2021-07-13T09:43:26+01:00
summary:

bpo-44472: Fix ltrace functionality when exceptions are raised (GH-26822) (GH-26830)

(cherry picked from commit 06cda808f149fae9b4c688f752b6eccd0d455ba4)

Co-authored-by: Pablo Galindo <Pablogsal at gmail.com>

Co-authored-by: Pablo Galindo <Pablogsal at gmail.com>

files:
A Misc/NEWS.d/next/Core and Builtins/2021-06-21-11-19-54.bpo-44472.Vvm1yn.rst
M 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
index 0000000000000..34fa2a9e8615f
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2021-06-21-11-19-54.bpo-44472.Vvm1yn.rst	
@@ -0,0 +1 @@
+Fix ltrace functionality when exceptions are raised. Patch by Pablo Galindo
diff --git a/Python/ceval.c b/Python/ceval.c
index 2674e46b3d606..6482c8892d43f 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -5385,11 +5385,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



More information about the Python-checkins mailing list