]> granicus.if.org Git - python/commitdiff
Issue #18408: Fix dict_repr(), don't call PyObject_Repr() with an exception set
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 17 Jul 2013 23:00:45 +0000 (01:00 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 17 Jul 2013 23:00:45 +0000 (01:00 +0200)
PyObject_Repr() can removes the current exception. For example, module_repr()
calls PyErr_Clear() if calling loader.module_repr(mod) failed.

Objects/dictobject.c

index 3243061b68bd1a5a4a33eb5a66f7b233715fcd6e..36c710ed5bcfd856024f94257cd4b187652a96cf 100644 (file)
@@ -1443,6 +1443,9 @@ dict_repr(PyDictObject *mp)
         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);