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

victor.stinner python-checkins at python.org
Tue Jul 16 23:09:22 CEST 2013


http://hg.python.org/cpython/rev/28ff7ac91477
changeset:   84675:28ff7ac91477
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Jul 16 22:24:44 2013 +0200
summary:
  Issue #18408: Py_ReprLeave() now saves/restores the current exception,
and ignores exceptions raised during the call

files:
  Objects/object.c |  13 +++++++++++--
  1 files changed, 11 insertions(+), 2 deletions(-)


diff --git a/Objects/object.c b/Objects/object.c
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1920,13 +1920,18 @@
     PyObject *dict;
     PyObject *list;
     Py_ssize_t i;
+    PyObject *error_type, *error_value, *error_traceback;
+
+    PyErr_Fetch(&error_type, &error_value, &error_traceback);
 
     dict = PyThreadState_GetDict();
     if (dict == NULL)
-        return;
+        goto finally;
+
     list = PyDict_GetItemString(dict, KEY);
     if (list == NULL || !PyList_Check(list))
-        return;
+        goto finally;
+
     i = PyList_GET_SIZE(list);
     /* Count backwards because we always expect obj to be list[-1] */
     while (--i >= 0) {
@@ -1935,6 +1940,10 @@
             break;
         }
     }
+
+finally:
+    /* ignore exceptions because there is no way to report them. */
+    PyErr_Restore(error_type, error_value, error_traceback);
 }
 
 /* Trashcan support. */

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


More information about the Python-checkins mailing list