Issue #25449: Iterating OrderedDict with keys with unstable hash now raises

KeyError in C implementations as well as in Python implementation.

Added tests for OrderedDict subclasses.
This commit is contained in:
Serhiy Storchaka 2015-11-04 22:05:38 +02:00
parent b25d09a15e
commit b45b7b2137
3 changed files with 90 additions and 61 deletions

View file

@ -1789,6 +1789,8 @@ odictiter_nextkey(odictiterobject *di)
/* Get the key. */
node = _odict_find_node(di->di_odict, di->di_current);
if (node == NULL) {
if (!PyErr_Occurred())
PyErr_SetObject(PyExc_KeyError, di->di_current);
/* Must have been deleted. */
Py_CLEAR(di->di_current);
return NULL;