summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-09-12 12:17:40 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-09-12 12:17:40 (GMT)
commit3c336c59157ea39f366a0562e710566873cc4fb1 (patch)
tree5c08f6077614cd548f7888e23965415468ee28d8 /Objects/dictobject.c
parent57f91ac95aec1922ba104019a81a6508485862c4 (diff)
downloadcpython-3c336c59157ea39f366a0562e710566873cc4fb1.zip
cpython-3c336c59157ea39f366a0562e710566873cc4fb1.tar.gz
cpython-3c336c59157ea39f366a0562e710566873cc4fb1.tar.bz2
Issue #28077: find_empty_slot() only supports combined dict
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 4bcc3db..8b88ec6 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -984,8 +984,9 @@ _PyDict_MaybeUntrack(PyObject *op)
}
/* Internal function to find slot for an item from its hash
- * when it is known that the key is not present in the dict.
- */
+ when it is known that the key is not present in the dict.
+
+ The dict must be combined. */
static Py_ssize_t
find_empty_slot(PyDictObject *mp, PyObject *key, Py_hash_t hash,
PyObject ***value_addr, Py_ssize_t *hashpos)
@@ -995,8 +996,10 @@ find_empty_slot(PyDictObject *mp, PyObject *key, Py_hash_t hash,
Py_ssize_t ix;
PyDictKeyEntry *ep, *ep0 = DK_ENTRIES(mp->ma_keys);
+ assert(!_PyDict_HasSplitTable(mp));
assert(hashpos != NULL);
assert(key != NULL);
+
if (!PyUnicode_CheckExact(key))
mp->ma_keys->dk_lookup = lookdict;
i = hash & mask;
@@ -2672,8 +2675,9 @@ PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *defaultobj)
val = defaultobj;
if (mp->ma_keys->dk_usable <= 0) {
/* Need to resize. */
- if (insertion_resize(mp) < 0)
+ if (insertion_resize(mp) < 0) {
return NULL;
+ }
find_empty_slot(mp, key, hash, &value_addr, &hashpos);
}
ix = mp->ma_keys->dk_nentries;