diff options
author | Kristján Valur Jónsson <sweskman@gmail.com> | 2014-03-05 13:47:57 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <sweskman@gmail.com> | 2014-03-05 13:47:57 (GMT) |
commit | 25dded041fe532fcb041b6e68582bf76b4968132 (patch) | |
tree | 3c70fceb3fe5ef98a17b85aa94704d20eb5a853d /Objects/tupleobject.c | |
parent | 4ca688edeb07de955e1ef67c11f0e327f12ffa6e (diff) | |
download | cpython-25dded041fe532fcb041b6e68582bf76b4968132.zip cpython-25dded041fe532fcb041b6e68582bf76b4968132.tar.gz cpython-25dded041fe532fcb041b6e68582bf76b4968132.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.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 123df8c..f815595 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -998,8 +998,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; |