diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2015-06-02 04:59:08 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2015-06-02 04:59:08 (GMT) |
commit | a762af74b2de734c44f7dc00358325d4485e2530 (patch) | |
tree | 8bd74eaf0c0ab40cbeb80491a9afd6ed4b555432 /Lib/test/test_collections.py | |
parent | fa1b47cc5a51095c43da5df0d6a042ec1f1b7d98 (diff) | |
download | cpython-a762af74b2de734c44f7dc00358325d4485e2530.zip cpython-a762af74b2de734c44f7dc00358325d4485e2530.tar.gz cpython-a762af74b2de734c44f7dc00358325d4485e2530.tar.bz2 |
Issue #24347: Set KeyError if PyDict_GetItemWithError returns NULL.
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r-- | Lib/test/test_collections.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 3f02129..931ac0f 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -2037,6 +2037,24 @@ class CPythonOrderedDictTests(OrderedDictTests, unittest.TestCase): del od[colliding] self.assertEqual(list(od.items()), [(key, ...), ('after', ...)]) + def test_issue24347(self): + OrderedDict = self.module.OrderedDict + + class Key: + def __hash__(self): + return randrange(100000) + + od = OrderedDict() + for i in range(100): + key = Key() + od[key] = i + + # These should not crash. + with self.assertRaises(KeyError): + repr(od) + with self.assertRaises(KeyError): + od.copy() + class PurePythonGeneralMappingTests(mapping_tests.BasicTestMappingProtocol): |