summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@wyplay.com>2013-08-26 11:49:06 (GMT)
committerVictor Stinner <vstinner@wyplay.com>2013-08-26 11:49:06 (GMT)
commite51321020c78f28571b499dcc284604217ef0eb0 (patch)
treea76445124b3a5ff54d28ed755263fbcfa4aff7a1 /Objects/object.c
parent0e1e04301badf92e1204bbeed3cb31a98eeed7f9 (diff)
downloadcpython-e51321020c78f28571b499dcc284604217ef0eb0.zip
cpython-e51321020c78f28571b499dcc284604217ef0eb0.tar.gz
cpython-e51321020c78f28571b499dcc284604217ef0eb0.tar.bz2
Issue #18408: _PyObject_Dump() now saves/restores the current exception
So it can be called even if an exception was raised
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 0561e09..006f0d4 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -406,11 +406,17 @@ _PyObject_Dump(PyObject* op)
#ifdef WITH_THREAD
PyGILState_STATE gil;
#endif
+ PyObject *error_type, *error_value, *error_traceback;
+
fprintf(stderr, "object : ");
#ifdef WITH_THREAD
gil = PyGILState_Ensure();
#endif
+
+ PyErr_Fetch(&error_type, &error_value, &error_traceback);
(void)PyObject_Print(op, stderr, 0);
+ PyErr_Restore(error_type, error_value, error_traceback);
+
#ifdef WITH_THREAD
PyGILState_Release(gil);
#endif