diff -r b86effa7e656 Objects/dictobject.c --- a/Objects/dictobject.c Sat Sep 17 17:30:05 2016 -0700 +++ b/Objects/dictobject.c Sun Sep 18 17:11:15 2016 +0800 @@ -710,13 +710,14 @@ } else { ep = &ep0[ix]; + assert(ep->me_key != NULL); if (ep->me_key == key) { *value_addr = &ep->me_value; if (hashpos != NULL) *hashpos = i; return ix; } - if (ep->me_key != NULL && ep->me_hash == hash) { + if (ep->me_hash == hash) { startkey = ep->me_key; Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); @@ -755,6 +756,7 @@ continue; } ep = &ep0[ix]; + assert(ep->me_key != NULL); if (ep->me_key == key) { if (hashpos != NULL) { *hashpos = i; @@ -762,7 +764,7 @@ *value_addr = &ep->me_value; return ix; } - if (ep->me_hash == hash && ep->me_key != NULL) { + if (ep->me_hash == hash) { startkey = ep->me_key; Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); @@ -822,9 +824,9 @@ } else { ep = &ep0[ix]; - /* only split table can be ix != DKIX_DUMMY && me_key == NULL */ assert(ep->me_key != NULL); - if (ep->me_key == key || (ep->me_hash == hash && unicode_eq(ep->me_key, key))) { + if (ep->me_key == key + || (ep->me_hash == hash && unicode_eq(ep->me_key, key))) { if (hashpos != NULL) *hashpos = i; *value_addr = &ep->me_value; @@ -849,10 +851,9 @@ continue; } ep = &ep0[ix]; + assert(ep->me_key != NULL); if (ep->me_key == key - || (ep->me_hash == hash - && ep->me_key != NULL - && unicode_eq(ep->me_key, key))) { + || (ep->me_hash == hash && unicode_eq(ep->me_key, key))) { *value_addr = &ep->me_value; if (hashpos != NULL) { *hashpos = i; @@ -962,7 +963,7 @@ } assert(ix >= 0); ep = &ep0[ix]; - assert(ep->me_key == NULL || PyUnicode_CheckExact(ep->me_key)); + assert(ep->me_key != NULL && PyUnicode_CheckExact(ep->me_key)); if (ep->me_key == key || (ep->me_hash == hash && unicode_eq(ep->me_key, key))) { if (hashpos != NULL) @@ -981,7 +982,7 @@ } assert(ix >= 0); ep = &ep0[ix]; - assert(ep->me_key == NULL || PyUnicode_CheckExact(ep->me_key)); + assert(ep->me_key != NULL && PyUnicode_CheckExact(ep->me_key)); if (ep->me_key == key || (ep->me_hash == hash && unicode_eq(ep->me_key, key))) { if (hashpos != NULL) @@ -2868,7 +2869,6 @@ PyTuple_SET_ITEM(res, 1, ep->me_value); ep->me_key = NULL; ep->me_value = NULL; - /* We can't dk_usable++ since there is DKIX_DUMMY in indices */ mp->ma_keys->dk_nentries = i; mp->ma_used--; mp->ma_version_tag = DICT_NEXT_VERSION(); @@ -2881,7 +2881,7 @@ { PyDictObject *mp = (PyDictObject *)op; PyDictKeysObject *keys = mp->ma_keys; - PyDictKeyEntry *entries = DK_ENTRIES(mp->ma_keys); + PyDictKeyEntry *entries = DK_ENTRIES(keys); Py_ssize_t i, n = keys->dk_nentries; if (keys->dk_lookup == lookdict) {