1
+ from test import support
1
2
from test .test_json import PyTest , CTest
2
3
3
4
@@ -69,21 +70,26 @@ def test_highly_nested_objects_decoding(self):
69
70
# test that loading highly-nested objects doesn't segfault when C
70
71
# accelerations are used. See #12017
71
72
with self .assertRaises (RecursionError ):
72
- self .loads ('{"a":' * 100000 + '1' + '}' * 100000 )
73
+ with support .infinite_recursion ():
74
+ self .loads ('{"a":' * 100000 + '1' + '}' * 100000 )
73
75
with self .assertRaises (RecursionError ):
74
- self .loads ('{"a":' * 100000 + '[1]' + '}' * 100000 )
76
+ with support .infinite_recursion ():
77
+ self .loads ('{"a":' * 100000 + '[1]' + '}' * 100000 )
75
78
with self .assertRaises (RecursionError ):
76
- self .loads ('[' * 100000 + '1' + ']' * 100000 )
79
+ with support .infinite_recursion ():
80
+ self .loads ('[' * 100000 + '1' + ']' * 100000 )
77
81
78
82
def test_highly_nested_objects_encoding (self ):
79
83
# See #12051
80
84
l , d = [], {}
81
85
for x in range (100000 ):
82
86
l , d = [l ], {'k' :d }
83
87
with self .assertRaises (RecursionError ):
84
- self .dumps (l )
88
+ with support .infinite_recursion ():
89
+ self .dumps (l )
85
90
with self .assertRaises (RecursionError ):
86
- self .dumps (d )
91
+ with support .infinite_recursion ():
92
+ self .dumps (d )
87
93
88
94
def test_endless_recursion (self ):
89
95
# See #12051
@@ -93,7 +99,8 @@ def default(self, o):
93
99
return [o ]
94
100
95
101
with self .assertRaises (RecursionError ):
96
- EndlessJSONEncoder (check_circular = False ).encode (5j )
102
+ with support .infinite_recursion ():
103
+ EndlessJSONEncoder (check_circular = False ).encode (5j )
97
104
98
105
99
106
class TestPyRecursion (TestRecursion , PyTest ): pass
0 commit comments