File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -1982,3 +1982,13 @@ def skip_if_broken_multiprocessing_synchronize():
1982
1982
synchronize .Lock (ctx = None )
1983
1983
except OSError as exc :
1984
1984
raise unittest .SkipTest (f"broken multiprocessing SemLock: { exc !r} " )
1985
+
1986
+
1987
+ @contextlib .contextmanager
1988
+ def infinite_recursion (max_depth = 75 ):
1989
+ original_depth = sys .getrecursionlimit ()
1990
+ try :
1991
+ sys .setrecursionlimit (max_depth )
1992
+ yield
1993
+ finally :
1994
+ sys .setrecursionlimit (original_depth )
Original file line number Diff line number Diff line change @@ -1101,15 +1101,17 @@ def test_recursion_direct(self):
1101
1101
e = ast .UnaryOp (op = ast .Not (), lineno = 0 , col_offset = 0 )
1102
1102
e .operand = e
1103
1103
with self .assertRaises (RecursionError ):
1104
- compile (ast .Expression (e ), "<test>" , "eval" )
1104
+ with support .infinite_recursion ():
1105
+ compile (ast .Expression (e ), "<test>" , "eval" )
1105
1106
1106
1107
def test_recursion_indirect (self ):
1107
1108
e = ast .UnaryOp (op = ast .Not (), lineno = 0 , col_offset = 0 )
1108
1109
f = ast .UnaryOp (op = ast .Not (), lineno = 0 , col_offset = 0 )
1109
1110
e .operand = f
1110
1111
f .operand = e
1111
1112
with self .assertRaises (RecursionError ):
1112
- compile (ast .Expression (e ), "<test>" , "eval" )
1113
+ with support .infinite_recursion ():
1114
+ compile (ast .Expression (e ), "<test>" , "eval" )
1113
1115
1114
1116
1115
1117
class ASTValidatorTests (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments