mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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:
parent
4ca688edeb
commit
25dded041f
8 changed files with 66 additions and 15 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue