mirror of
https://github.com/python/cpython.git
synced 2025-09-15 05:06:12 +00:00
Fix error introduced by r58288; if a tuple is length 0 return its repr and
don't worry about any self-referring tuples.
This commit is contained in:
parent
0b14f243c4
commit
31ba8480d8
1 changed files with 4 additions and 4 deletions
|
@ -216,6 +216,10 @@ tuplerepr(PyTupleObject *v)
|
||||||
PyObject *s, *temp;
|
PyObject *s, *temp;
|
||||||
PyObject *pieces, *result = NULL;
|
PyObject *pieces, *result = NULL;
|
||||||
|
|
||||||
|
n = Py_Size(v);
|
||||||
|
if (n == 0)
|
||||||
|
return PyString_FromString("()");
|
||||||
|
|
||||||
/* While not mutable, it is still possible to end up with a cycle in a
|
/* While not mutable, it is still possible to end up with a cycle in a
|
||||||
tuple through an object that stores itself within a tuple (and thus
|
tuple through an object that stores itself within a tuple (and thus
|
||||||
infinitely asks for the repr of itself). This should only be
|
infinitely asks for the repr of itself). This should only be
|
||||||
|
@ -225,10 +229,6 @@ tuplerepr(PyTupleObject *v)
|
||||||
return i > 0 ? PyString_FromString("(...)") : NULL;
|
return i > 0 ? PyString_FromString("(...)") : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = Py_Size(v);
|
|
||||||
if (n == 0)
|
|
||||||
return PyString_FromString("()");
|
|
||||||
|
|
||||||
pieces = PyTuple_New(n);
|
pieces = PyTuple_New(n);
|
||||||
if (pieces == NULL)
|
if (pieces == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue