Issue #18408: Py_ReprLeave() now saves/restores the current exception,

and ignores exceptions raised during the call
This commit is contained in:
Victor Stinner 2013-07-16 22:24:44 +02:00
parent ac2a4fe8a2
commit 1b63493ed1
1 changed files with 11 additions and 2 deletions

View File

@ -1920,13 +1920,18 @@ Py_ReprLeave(PyObject *obj)
PyObject *dict;
PyObject *list;
Py_ssize_t i;
PyObject *error_type, *error_value, *error_traceback;
PyErr_Fetch(&error_type, &error_value, &error_traceback);
dict = PyThreadState_GetDict();
if (dict == NULL)
return;
goto finally;
list = PyDict_GetItemString(dict, KEY);
if (list == NULL || !PyList_Check(list))
return;
goto finally;
i = PyList_GET_SIZE(list);
/* Count backwards because we always expect obj to be list[-1] */
while (--i >= 0) {
@ -1935,6 +1940,10 @@ Py_ReprLeave(PyObject *obj)
break;
}
}
finally:
/* ignore exceptions because there is no way to report them. */
PyErr_Restore(error_type, error_value, error_traceback);
}
/* Trashcan support. */