(original) (raw)

changeset: 103707:0e986b81cc1c user: Victor Stinner victor.stinner@gmail.com date: Mon Sep 12 14:17:40 2016 +0200 files: Objects/dictobject.c description: Issue #28077: find_empty_slot() only supports combined dict diff -r 2558bc4a4ebf -r 0e986b81cc1c Objects/dictobject.c --- a/Objects/dictobject.c Mon Sep 12 13:37:07 2016 +0200 +++ b/Objects/dictobject.c Mon Sep 12 14:17:40 2016 +0200 @@ -984,8 +984,9 @@ } /* 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 @@ 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 @@ 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; /victor.stinner@gmail.com