diff options
author | Brett Cannon <bcannon@gmail.com> | 2007-09-30 20:37:19 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2007-09-30 20:37:19 (GMT) |
commit | 31ba8480d823f2c424d77ccd8c446b79ca48c1ce (patch) | |
tree | 487c63ac2f54a4417feecc85acee1379c9a9cfbe /Objects/tupleobject.c | |
parent | 0b14f243c4ba95db67604261131400cd92736df9 (diff) | |
download | cpython-31ba8480d823f2c424d77ccd8c446b79ca48c1ce.zip cpython-31ba8480d823f2c424d77ccd8c446b79ca48c1ce.tar.gz cpython-31ba8480d823f2c424d77ccd8c446b79ca48c1ce.tar.bz2 |
Fix error introduced by r58288; if a tuple is length 0 return its repr and
don't worry about any self-referring tuples.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r-- | Objects/tupleobject.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 38304dd..b1704f7 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -216,6 +216,10 @@ tuplerepr(PyTupleObject *v) PyObject *s, *temp; 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 tuple through an object that stores itself within a tuple (and thus infinitely asks for the repr of itself). This should only be @@ -225,10 +229,6 @@ tuplerepr(PyTupleObject *v) return i > 0 ? PyString_FromString("(...)") : NULL; } - n = Py_Size(v); - if (n == 0) - return PyString_FromString("()"); - pieces = PyTuple_New(n); if (pieces == NULL) return NULL; |