summaryrefslogtreecommitdiffstats
path: root/Objects/tupleobject.c
diff options
context:
space:
mode:
authorKristján Valur Jónsson <sweskman@gmail.com>2014-03-05 15:23:07 (GMT)
committerKristján Valur Jónsson <sweskman@gmail.com>2014-03-05 15:23:07 (GMT)
commitc5cc5011ac33f96a8bf28e3ba088980fd5e71d7a (patch)
tree21c775f7b89e60348ed587d1bb983b2cd61e723b /Objects/tupleobject.c
parent25ea45db81540b8c589c65edf2564c04461b1f34 (diff)
parent25dded041fe532fcb041b6e68582bf76b4968132 (diff)
downloadcpython-c5cc5011ac33f96a8bf28e3ba088980fd5e71d7a.zip
cpython-c5cc5011ac33f96a8bf28e3ba088980fd5e71d7a.tar.gz
cpython-c5cc5011ac33f96a8bf28e3ba088980fd5e71d7a.tar.bz2
Make the various iterators' "setstate" sliently and consistently clip the
index. This avoids the possibility of setting an iterator to an invalid state.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r--Objects/tupleobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index c63afcc..6fd4db3 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -1011,8 +1011,8 @@ tupleiter_setstate(tupleiterobject *it, PyObject *state)
if (it->it_seq != NULL) {
if (index < 0)
index = 0;
- else if (it->it_seq != NULL && index > PyTuple_GET_SIZE(it->it_seq))
- index = PyTuple_GET_SIZE(it->it_seq);
+ else if (index > PyTuple_GET_SIZE(it->it_seq))
+ index = PyTuple_GET_SIZE(it->it_seq); /* exhausted iterator */
it->it_index = index;
}
Py_RETURN_NONE;