summaryrefslogtreecommitdiffstats
path: root/Objects/odictobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-30 15:25:45 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-30 15:25:45 (GMT)
commitb7d14a09c245f1e78911208b7f65bd09d7c03f2c (patch)
tree875ae469993805b05545c3653664db4667d73e88 /Objects/odictobject.c
parent944078786797b03b415d76b0b2d7f3fb8570b9a4 (diff)
parent043868393969224947c03617475d31f64ea59634 (diff)
downloadcpython-b7d14a09c245f1e78911208b7f65bd09d7c03f2c.zip
cpython-b7d14a09c245f1e78911208b7f65bd09d7c03f2c.tar.gz
cpython-b7d14a09c245f1e78911208b7f65bd09d7c03f2c.tar.bz2
Merge from 3.5.
Diffstat (limited to 'Objects/odictobject.c')
-rw-r--r--Objects/odictobject.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index be61d4e..22b1f1d 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -1102,13 +1102,28 @@ _odict_popkey_hash(PyObject *od, PyObject *key, PyObject *failobj,
}
/* Now delete the value from the dict. */
- 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;
+ 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);
+ }
}
}
}