diff -r fbe29ca8192b Lib/test/test_dict.py --- a/Lib/test/test_dict.py Tue Sep 13 13:27:41 2016 +0200 +++ b/Lib/test/test_dict.py Tue Sep 13 22:10:43 2016 +0800 @@ -874,7 +874,7 @@ @support.cpython_only def test_splittable_pop(self): """split table must be combined when d.pop(k)""" - a, b = self.make_shared_key_dict(2) + a, b, c = self.make_shared_key_dict(3) orig_size = sys.getsizeof(a) @@ -891,6 +891,11 @@ self.assertEqual(list(a), ['x', 'z', 'y']) self.assertEqual(list(b), ['x', 'y', 'z']) + # issue 28120 + c['a'] = 4 + with self.assertRaises(KeyError): + b.pop('a') + @support.cpython_only def test_splittable_popitem(self): """split table must be combined when d.popitem()""" diff -r fbe29ca8192b Objects/dictobject.c --- a/Objects/dictobject.c Tue Sep 13 13:27:41 2016 +0200 +++ b/Objects/dictobject.c Tue Sep 13 22:10:43 2016 +0800 @@ -1721,7 +1721,7 @@ ix = (mp->ma_keys->dk_lookup)(mp, key, hash, &value_addr, &hashpos); if (ix == DKIX_ERROR) return NULL; - if (ix == DKIX_EMPTY) { + if (ix == DKIX_EMPTY || *value_addr == NULL) { if (deflt) { Py_INCREF(deflt); return deflt;