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

So it can be called even if an exception was raised
This commit is contained in:
Victor Stinner 2013-08-26 13:49:06 +02:00
parent 0e1e04301b
commit e51321020c
1 changed files with 6 additions and 0 deletions

View 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