mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +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
|
|
@ -2811,6 +2811,8 @@ listiter_setstate(listiterobject *it, PyObject *state)
|
|||
if (it->it_seq != NULL) {
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
else if (index > PyList_GET_SIZE(it->it_seq))
|
||||
index = PyList_GET_SIZE(it->it_seq); /* iterator exhausted */
|
||||
it->it_index = index;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue