Skip to content

Commit 4a0f1df

Browse files
bpo-44472: Fix ltrace functionality when exceptions are raised (GH-26822) (GH-26830)
(cherry picked from commit 06cda80) Co-authored-by: Pablo Galindo <[email protected]> Co-authored-by: Pablo Galindo <[email protected]>
1 parent 7223ce3 commit 4a0f1df

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix ltrace functionality when exceptions are raised. Patch by Pablo Galindo

Python/ceval.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5385,11 +5385,14 @@ static int
53855385
prtrace(PyThreadState *tstate, PyObject *v, const char *str)
53865386
{
53875387
printf("%s ", str);
5388+
PyObject *type, *value, *traceback;
5389+
PyErr_Fetch(&type, &value, &traceback);
53885390
if (PyObject_Print(v, stdout, 0) != 0) {
53895391
/* Don't know what else to do */
53905392
_PyErr_Clear(tstate);
53915393
}
53925394
printf("\n");
5395+
PyErr_Restore(type, value, traceback);
53935396
return 1;
53945397
}
53955398
#endif

0 commit comments

Comments
 (0)