mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-36452: dictiter: track maximum iteration count (GH-12596)
This commit is contained in:
parent
738cb42a14
commit
796cc6e3ad
3 changed files with 16 additions and 0 deletions
|
@ -3543,6 +3543,12 @@ dictiter_iternextkey(dictiterobject *di)
|
|||
goto fail;
|
||||
key = entry_ptr->me_key;
|
||||
}
|
||||
// We found an element (key), but did not expect it
|
||||
if (di->len == 0) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"dictionary keys changed during iteration");
|
||||
goto fail;
|
||||
}
|
||||
di->di_pos = i+1;
|
||||
di->len--;
|
||||
Py_INCREF(key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue