Fix _PyDict_Pop() on pending key

Issue #28120: Fix dict.pop() for splitted dictionary when trying to remove a
"pending key" (Not yet inserted in split-table).

Patch by Xiang Zhang.
This commit is contained in:
Victor Stinner 2016-09-13 16:56:38 +02:00
parent 9926480b6a
commit d0ad11f6b4
3 changed files with 13 additions and 1 deletions

View file

@ -891,6 +891,15 @@ class DictTest(unittest.TestCase):
self.assertEqual(list(a), ['x', 'z', 'y'])
self.assertEqual(list(b), ['x', 'y', 'z'])
@support.cpython_only
def test_splittable_pop_pending(self):
"""pop a pending key in a splitted table should not crash"""
a, b = self.make_shared_key_dict(2)
a['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()"""