diff options
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c index 77ddb1d..40b8b42 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -423,7 +423,12 @@ _PyObject_Str(PyObject *v) if (Py_Type(v)->tp_str == NULL) return PyObject_Repr(v); + /* It is possible for a type to have a tp_str representation that loops + infinitely. */ + if (Py_EnterRecursiveCall(" while getting the str of an object")) + return NULL; res = (*Py_Type(v)->tp_str)(v); + Py_LeaveRecursiveCall(); if (res == NULL) return NULL; if (!(PyString_Check(res) || PyUnicode_Check(res))) { |