changeset: 98984:b391e97ccfe5 parent: 98982:51f3547da99c parent: 98983:1594c23d8c2f user: Serhiy Storchaka date: Fri Nov 06 11:07:31 2015 +0200 description: Issue #24726: Revert setting the value on the dict if _odict_add_new_node() fails. diff -r 51f3547da99c -r b391e97ccfe5 Objects/odictobject.c --- a/Objects/odictobject.c Fri Nov 06 10:40:05 2015 +0200 +++ b/Objects/odictobject.c Fri Nov 06 11:07:31 2015 +0200 @@ -1721,7 +1721,13 @@ int res = PyDict_SetItem(od, key, value); if (res == 0) { res = _odict_add_new_node((PyODictObject *)od, key); - /* XXX Revert setting the value on the dict? */ + if (res < 0) { + /* Revert setting the value on the dict */ + PyObject *exc, *val, *tb; + PyErr_Fetch(&exc, &val, &tb); + (void) PyDict_DelItem(od, key); + _PyErr_ChainExceptions(exc, val, tb); + } } return res; };