From: Victor Stinner Date: Mon, 26 Aug 2013 11:49:06 +0000 (+0200) Subject: Issue #18408: _PyObject_Dump() now saves/restores the current exception X-Git-Tag: v3.4.0a2~107 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e51321020c78f28571b499dcc284604217ef0eb0;p=python Issue #18408: _PyObject_Dump() now saves/restores the current exception So it can be called even if an exception was raised --- diff --git a/Objects/object.c b/Objects/object.c index 0561e09f86..006f0d4dbc 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