bpo-32137: The repr of deeply nested dict now raises a RecursionError (#4570)

instead of crashing due to a stack overflow.

This perhaps will fix similar problems in other extension types.
This commit is contained in:
Serhiy Storchaka 2017-12-03 22:12:11 +02:00 committed by GitHub
parent eea3cc1ef0
commit 1fb72d2ad2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 9 deletions

View file

@ -468,6 +468,12 @@ class DictTest(unittest.TestCase):
d = {1: BadRepr()}
self.assertRaises(Exc, repr, d)
def test_repr_deep(self):
d = {}
for i in range(sys.getrecursionlimit() + 100):
d = {1: d}
self.assertRaises(RecursionError, repr, d)
def test_eq(self):
self.assertEqual({}, {})
self.assertEqual({1: 2}, {1: 2})