[Python-checkins] cpython: Issue #18408: _PyObject_Dump() now saves/restores the current exception

victor.stinner python-checkins at python.org
Mon Aug 26 14:06:57 CEST 2013


http://hg.python.org/cpython/rev/79ce25c70795
changeset:   85414:79ce25c70795
user:        Victor Stinner <vstinner at wyplay.com>
date:        Mon Aug 26 13:49:06 2013 +0200
summary:
  Issue #18408: _PyObject_Dump() now saves/restores the current exception

So it can be called even if an exception was raised

files:
  Objects/object.c |  6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)


diff --git a/Objects/object.c b/Objects/object.c
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -406,11 +406,17 @@
 #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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list