diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2015-06-01 22:59:08 -0600 |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2015-06-01 22:59:08 -0600 |
commit | 4949722beab2bc2f79717c6779bed1544993a2d2 (patch) | |
tree | bc63abe4203dec9d067e2148b43f332215c43f9a /Lib/test/test_collections.py | |
parent | 8c33d6b64930fdd5c4eb592578c4bd097ea5e7b6 (diff) | |
download | cpython-4949722beab2bc2f79717c6779bed1544993a2d2.tar.gz |
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 3f02129c1d..931ac0ff0f 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): |