summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 674180d..a0d651d 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -463,7 +463,12 @@ PyObject_Repr(PyObject *v)
assert(!PyErr_Occurred());
#endif
+ /* It is possible for a type to have a tp_repr representation that loops
+ infinitely. */
+ if (Py_EnterRecursiveCall(" while getting the repr of an object"))
+ return NULL;
res = (*v->ob_type->tp_repr)(v);
+ Py_LeaveRecursiveCall();
if (res == NULL)
return NULL;
if (!PyUnicode_Check(res)) {