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

(cherry picked from commit 06cda808f1)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-07-12 08:11:10 -07:00 committed by GitHub
parent c89f0b2587
commit 6fb4248cd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -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