File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -3199,3 +3199,13 @@ def skip_if_broken_multiprocessing_synchronize():
3199
3199
synchronize .Lock (ctx = None )
3200
3200
except OSError as exc :
3201
3201
raise unittest .SkipTest (f"broken multiprocessing SemLock: { exc !r} " )
3202
+
3203
+
3204
+ @contextlib .contextmanager
3205
+ def infinite_recursion (max_depth = 75 ):
3206
+ original_depth = sys .getrecursionlimit ()
3207
+ try :
3208
+ sys .setrecursionlimit (max_depth )
3209
+ yield
3210
+ finally :
3211
+ sys .setrecursionlimit (original_depth )
Original file line number Diff line number Diff line change @@ -1031,15 +1031,17 @@ def test_recursion_direct(self):
1031
1031
e = ast .UnaryOp (op = ast .Not (), lineno = 0 , col_offset = 0 )
1032
1032
e .operand = e
1033
1033
with self .assertRaises (RecursionError ):
1034
- compile (ast .Expression (e ), "<test>" , "eval" )
1034
+ with support .infinite_recursion ():
1035
+ compile (ast .Expression (e ), "<test>" , "eval" )
1035
1036
1036
1037
def test_recursion_indirect (self ):
1037
1038
e = ast .UnaryOp (op = ast .Not (), lineno = 0 , col_offset = 0 )
1038
1039
f = ast .UnaryOp (op = ast .Not (), lineno = 0 , col_offset = 0 )
1039
1040
e .operand = f
1040
1041
f .operand = e
1041
1042
with self .assertRaises (RecursionError ):
1042
- compile (ast .Expression (e ), "<test>" , "eval" )
1043
+ with support .infinite_recursion ():
1044
+ compile (ast .Expression (e ), "<test>" , "eval" )
1043
1045
1044
1046
1045
1047
class ASTValidatorTests (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments