Fix a possible segfault from recursing too deep to get the repr of a list.
Closes issue #1096.
diff --git a/Objects/listobject.c b/Objects/listobject.c
index c0621dc..92bad8c 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -324,7 +324,10 @@
so must refetch the list size on each iteration. */
for (i = 0; i < Py_Size(v); ++i) {
int status;
+ if (Py_EnterRecursiveCall(" while getting the repr of a list"))
+ goto Done;
s = PyObject_Repr(v->ob_item[i]);
+ Py_LeaveRecursiveCall();
if (s == NULL)
goto Done;
status = PyList_Append(pieces, s);