Skip to content

Commit 6fb4248

Browse files
bpo-44472: Fix ltrace functionality when exceptions are raised (GH-26822) (#26831)
(cherry picked from commit 06cda80) Co-authored-by: Pablo Galindo <[email protected]>
1 parent c89f0b2 commit 6fb4248

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
@@ -4598,11 +4598,14 @@ static int
45984598
prtrace(PyThreadState *tstate, PyObject *v, const char *str)
45994599
{
46004600
printf("%s ", str);
4601+
PyObject *type, *value, *traceback;
4602+
PyErr_Fetch(&type, &value, &traceback);
46014603
if (PyObject_Print(v, stdout, 0) != 0) {
46024604
/* Don't know what else to do */
46034605
_PyErr_Clear(tstate);
46044606
}
46054607
printf("\n");
4608+
PyErr_Restore(type, value, traceback);
46064609
return 1;
46074610
}
46084611
#endif

0 commit comments

Comments
 (0)