summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-16 20:24:44 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-16 20:24:44 (GMT)
commit1b63493ed18a93201ad0c09bfc849a13d9f01632 (patch)
treeb9b54282744f9ac4ed0eba324bd87c38685a546f /Objects/object.c
parentac2a4fe8a20961590cc20cde2afd7cf0fc9ce8b2 (diff)
downloadcpython-1b63493ed18a93201ad0c09bfc849a13d9f01632.zip
cpython-1b63493ed18a93201ad0c09bfc849a13d9f01632.tar.gz
cpython-1b63493ed18a93201ad0c09bfc849a13d9f01632.tar.bz2
Issue #18408: Py_ReprLeave() now saves/restores the current exception,
and ignores exceptions raised during the call
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Objects/object.c b/Objects/object.c
index d382a3c..700e8be 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -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. */