From f97dfd7b59c6472dc209f85c8f0a479dd6649859 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 18 Jul 2013 01:00:45 +0200 Subject: 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. --- Objects/dictobject.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 3243061..36c710e 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -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); -- cgit v0.12