|
8 | 8 | import unittest |
9 | 9 | import weakref |
10 | 10 | from test import support |
11 | | -from test.support import import_helper |
| 11 | +from test.support import import_helper, C_RECURSION_LIMIT |
12 | 12 |
|
13 | 13 |
|
14 | 14 | class DictTest(unittest.TestCase): |
@@ -599,7 +599,7 @@ def __repr__(self): |
599 | 599 | @unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows') |
600 | 600 | def test_repr_deep(self): |
601 | 601 | d = {} |
602 | | - for i in range(sys.getrecursionlimit() + 100): |
| 602 | + for i in range(C_RECURSION_LIMIT + 1): |
603 | 603 | d = {1: d} |
604 | 604 | self.assertRaises(RecursionError, repr, d) |
605 | 605 |
|
@@ -1099,6 +1099,21 @@ def __init__(self, order): |
1099 | 1099 | d.update(o.__dict__) |
1100 | 1100 | self.assertEqual(list(d), ["c", "b", "a"]) |
1101 | 1101 |
|
| 1102 | + @support.cpython_only |
| 1103 | + def test_splittable_to_generic_combinedtable(self): |
| 1104 | + """split table must be correctly resized and converted to generic combined table""" |
| 1105 | + class C: |
| 1106 | + pass |
| 1107 | + |
| 1108 | + a = C() |
| 1109 | + a.x = 1 |
| 1110 | + d = a.__dict__ |
| 1111 | + before_resize = sys.getsizeof(d) |
| 1112 | + d[2] = 2 # split table is resized to a generic combined table |
| 1113 | + |
| 1114 | + self.assertGreater(sys.getsizeof(d), before_resize) |
| 1115 | + self.assertEqual(list(d), ['x', 2]) |
| 1116 | + |
1102 | 1117 | def test_iterator_pickling(self): |
1103 | 1118 | for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
1104 | 1119 | data = {1:"a", 2:"b", 3:"c"} |
|
0 commit comments