Make the various iterators' "setstate" sliently and consistently clip the

index.  This avoids the possibility of setting an iterator to an invalid
state.
This commit is contained in:
Kristján Valur Jónsson 2014-03-05 15:23:07 +00:00
commit c5cc5011ac
8 changed files with 66 additions and 15 deletions

View file

@ -2838,6 +2838,8 @@ arrayiter_setstate(arrayiterobject *it, PyObject *state)
return NULL;
if (index < 0)
index = 0;
else if (index > Py_SIZE(it->ao))
index = Py_SIZE(it->ao); /* iterator exhausted */
it->index = index;
Py_RETURN_NONE;
}