diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-07-05 00:55:16 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-07-05 00:55:16 (GMT) |
commit | a82f77fb00ca3bd3eb27a6a5d77a19eadcf0ba31 (patch) | |
tree | 8512d60d455368264a72505c27fb6164925107dc /Lib/test/test_dict.py | |
parent | dac3ab84c73eb99265f0cf4863897c8e8302dbfd (diff) | |
download | cpython-a82f77fb00ca3bd3eb27a6a5d77a19eadcf0ba31.zip cpython-a82f77fb00ca3bd3eb27a6a5d77a19eadcf0ba31.tar.gz cpython-a82f77fb00ca3bd3eb27a6a5d77a19eadcf0ba31.tar.bz2 |
protect against mutation of the dict during insertion (closes #24407)
Diffstat (limited to 'Lib/test/test_dict.py')
-rw-r--r-- | Lib/test/test_dict.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py index a388959..bd3040a 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -906,6 +906,21 @@ class DictTest(unittest.TestCase): f.a = 'a' self.assertEqual(f.__dict__, {1:1, 'a':'a'}) + def test_merge_and_mutate(self): + class X: + def __hash__(self): + return 0 + + def __eq__(self, o): + other.clear() + return False + + l = [(i,0) for i in range(1, 1337)] + other = dict(l) + other[X()] = 0 + d = {X(): 0, 1: 1} + self.assertRaises(RuntimeError, d.update, other) + from test import mapping_tests class GeneralMappingTests(mapping_tests.BasicTestMappingProtocol): |