mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
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:
commit
c5cc5011ac
8 changed files with 66 additions and 15 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue