diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-25 12:36:56 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-25 12:36:56 (GMT) |
commit | 1faf9025b5d599d66acac0f33d1500a2ff386368 (patch) | |
tree | 908ef4fcedd4efaa26bd16219d1b4e6fde604e48 /Objects | |
parent | ecb90182f59c4929a395759896d1abea4e408f39 (diff) | |
parent | 4832580596e36805a2a2c206a3ce919260b16867 (diff) | |
download | cpython-1faf9025b5d599d66acac0f33d1500a2ff386368.zip cpython-1faf9025b5d599d66acac0f33d1500a2ff386368.tar.gz cpython-1faf9025b5d599d66acac0f33d1500a2ff386368.tar.bz2 |
Issue #27275: Fixed implementation of pop() and popitem() methods in
subclasses of accelerated OrderedDict.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/odictobject.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/Objects/odictobject.c b/Objects/odictobject.c index 22b1f1d..be61d4e 100644 --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -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; } } } |