Issue #27275: Fixed implementation of pop() and popitem() methods in

subclasses of accelerated OrderedDict.
This commit is contained in:
Serhiy Storchaka 2016-10-25 15:36:56 +03:00
commit 1faf9025b5
3 changed files with 69 additions and 22 deletions

View file

@ -1102,28 +1102,13 @@ _odict_popkey_hash(PyObject *od, PyObject *key, PyObject *failobj,
}
/* Now delete the value from the dict. */
if (PyODict_CheckExact(od)) {
if (node != NULL) {
value = _PyDict_GetItem_KnownHash(od, key, hash); /* borrowed */
if (value != NULL) {
Py_INCREF(value);
if (_PyDict_DelItem_KnownHash(od, key, hash) < 0) {
Py_DECREF(value);
return NULL;
}
}
}
}
else {
int exists = PySequence_Contains(od, key);
if (exists < 0)
return NULL;
if (exists) {
value = PyObject_GetItem(od, key);
if (value != NULL) {
if (PyObject_DelItem(od, key) == -1) {
Py_CLEAR(value);
}
if (node != NULL) {
value = _PyDict_GetItem_KnownHash(od, key, hash); /* borrowed */
if (value != NULL) {
Py_INCREF(value);
if (_PyDict_DelItem_KnownHash(od, key, hash) < 0) {
Py_DECREF(value);
return NULL;
}
}
}