Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e513210

Browse files
committed
Issue #18408: _PyObject_Dump() now saves/restores the current exception
So it can be called even if an exception was raised
1 parent 0e1e043 commit e513210

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Objects/object.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,17 @@ _PyObject_Dump(PyObject* op)
406406
#ifdef WITH_THREAD
407407
PyGILState_STATE gil;
408408
#endif
409+
PyObject *error_type, *error_value, *error_traceback;
410+
409411
fprintf(stderr, "object : ");
410412
#ifdef WITH_THREAD
411413
gil = PyGILState_Ensure();
412414
#endif
415+
416+
PyErr_Fetch(&error_type, &error_value, &error_traceback);
413417
(void)PyObject_Print(op, stderr, 0);
418+
PyErr_Restore(error_type, error_value, error_traceback);
419+
414420
#ifdef WITH_THREAD
415421
PyGILState_Release(gil);
416422
#endif

0 commit comments

Comments
 (0)