diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2017-12-03 20:12:11 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-03 20:12:11 (GMT) |
| commit | 1fb72d2ad243c965d4432b4e93884064001a2607 (patch) | |
| tree | 00296a976e5e386a94c0bb6f8ed535b1c30621f5 /Lib/test/mapping_tests.py | |
| parent | eea3cc1ef0dec0af193eedb4c1164263fbdfd8cc (diff) | |
| download | cpython-1fb72d2ad243c965d4432b4e93884064001a2607.zip cpython-1fb72d2ad243c965d4432b4e93884064001a2607.tar.gz cpython-1fb72d2ad243c965d4432b4e93884064001a2607.tar.bz2 | |
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.
Diffstat (limited to 'Lib/test/mapping_tests.py')
| -rw-r--r-- | Lib/test/mapping_tests.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/mapping_tests.py b/Lib/test/mapping_tests.py index ff82f4e..53f29f6 100644 --- a/Lib/test/mapping_tests.py +++ b/Lib/test/mapping_tests.py @@ -1,6 +1,7 @@ # tests common to dict and UserDict import unittest import collections +import sys class BasicTestMappingProtocol(unittest.TestCase): @@ -619,6 +620,14 @@ class TestHashMappingProtocol(TestMappingProtocol): d = self._full_mapping({1: BadRepr()}) self.assertRaises(Exc, repr, d) + def test_repr_deep(self): + d = self._empty_mapping() + for i in range(sys.getrecursionlimit() + 100): + d0 = d + d = self._empty_mapping() + d[1] = d0 + self.assertRaises(RecursionError, repr, d) + def test_eq(self): self.assertEqual(self._empty_mapping(), self._empty_mapping()) self.assertEqual(self._full_mapping({1: 2}), |
