diff options
Diffstat (limited to 'Modules/collectionsmodule.c')
-rw-r--r-- | Modules/collectionsmodule.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Modules/collectionsmodule.c b/Modules/collectionsmodule.c index 9d128fc959..dd3c0b7d8f 100644 --- a/Modules/collectionsmodule.c +++ b/Modules/collectionsmodule.c @@ -1217,7 +1217,17 @@ defdict_repr(defdictobject *dd) if (dd->default_factory == NULL) defrepr = PyString_FromString("None"); else - defrepr = PyObject_Repr(dd->default_factory); + { + int status = Py_ReprEnter(dd->default_factory); + if (status != 0) { + if (status < 0) + return NULL; + defrepr = PyString_FromString("..."); + } + else + defrepr = PyObject_Repr(dd->default_factory); + Py_ReprLeave(dd->default_factory); + } if (defrepr == NULL) { Py_DECREF(baserepr); return NULL; |