From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 12 Jul 2021 15:11:10 +0000 (-0700) Subject: bpo-44472: Fix ltrace functionality when exceptions are raised (GH-26822) (#26831) X-Git-Tag: v3.9.7~169 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6fb4248cd9502f50dd089fdcf548d735dcfd981e;p=thirdparty%2FPython%2Fcpython.git bpo-44472: Fix ltrace functionality when exceptions are raised (GH-26822) (#26831) (cherry picked from commit 06cda808f149fae9b4c688f752b6eccd0d455ba4) Co-authored-by: Pablo Galindo --- 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 000000000000..34fa2a9e8615 --- /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 91e879e80420..86a5d81b7669 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4598,11 +4598,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