[Python-checkins] cpython: Issue #18408: Fix dict_repr(), don't call PyObject_Repr() with an exception set

victor.stinner python-checkins at python.org
Thu Jul 18 01:46:20 CEST 2013


http://hg.python.org/cpython/rev/161de66cae49
changeset:   84702:161de66cae49
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Jul 18 01:00:45 2013 +0200
summary:
  Issue #18408: Fix dict_repr(), don't call PyObject_Repr() with an exception set

PyObject_Repr() can removes the current exception. For example, module_repr()
calls PyErr_Clear() if calling loader.module_repr(mod) failed.

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


diff --git a/Objects/dictobject.c b/Objects/dictobject.c
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1443,6 +1443,9 @@
         Py_INCREF(value);
         s = PyObject_Repr(key);
         PyUnicode_Append(&s, colon);
+        if (s == NULL)
+            goto Done;
+
         PyUnicode_AppendAndDel(&s, PyObject_Repr(value));
         Py_DECREF(key);
         Py_DECREF(value);

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


More information about the Python-checkins mailing list