]> granicus.if.org Git - python/commitdiff
Issue #18408: _PyObject_Dump() now saves/restores the current exception
authorVictor Stinner <vstinner@wyplay.com>
Mon, 26 Aug 2013 11:49:06 +0000 (13:49 +0200)
committerVictor Stinner <vstinner@wyplay.com>
Mon, 26 Aug 2013 11:49:06 +0000 (13:49 +0200)
So it can be called even if an exception was raised

Objects/object.c

index 0561e09f8641021529ed79303ea26a4c8584e9ef..006f0d4dbc343eef1253b04c194e33f89e195a97 100644 (file)
@@ -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