From 06cda808f149fae9b4c688f752b6eccd0d455ba4 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Mon, 21 Jun 2021 16:23:53 +0100 Subject: bpo-44472: Fix ltrace functionality when exceptions are raised (GH-26822) --- Python/ceval.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Python') diff --git a/Python/ceval.c b/Python/ceval.c index b5e3dd53c8..9c11640ec6 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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 -- cgit v1.2.1