summaryrefslogtreecommitdiff
path: root/Objects/odictobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-25 15:33:23 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-25 15:33:23 +0300
commitdfc86dfd1c265c157e38591c50432a74290ed70c (patch)
treee4dc986dba92c0f9cd0ad59de5beaf23858cbb0d /Objects/odictobject.c
parent9778d32e8152b9fb5d7ef839e58f09ddc0f88201 (diff)
downloadcpython-dfc86dfd1c265c157e38591c50432a74290ed70c.tar.gz
Issue #27275: Fixed implementation of pop() and popitem() methods in
subclasses of accelerated OrderedDict.
Diffstat (limited to 'Objects/odictobject.c')
-rw-r--r--Objects/odictobject.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index a6963d7d53..b4940e39ec 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -1099,28 +1099,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;
}
}
}