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():
19821982 synchronize .Lock (ctx = None )
19831983 except OSError as exc :
19841984 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):
11011101 e = ast .UnaryOp (op = ast .Not (), lineno = 0 , col_offset = 0 )
11021102 e .operand = e
11031103 with self .assertRaises (RecursionError ):
1104- compile (ast .Expression (e ), "<test>" , "eval" )
1104+ with support .infinite_recursion ():
1105+ compile (ast .Expression (e ), "<test>" , "eval" )
11051106
11061107 def test_recursion_indirect (self ):
11071108 e = ast .UnaryOp (op = ast .Not (), lineno = 0 , col_offset = 0 )
11081109 f = ast .UnaryOp (op = ast .Not (), lineno = 0 , col_offset = 0 )
11091110 e .operand = f
11101111 f .operand = e
11111112 with self .assertRaises (RecursionError ):
1112- compile (ast .Expression (e ), "<test>" , "eval" )
1113+ with support .infinite_recursion ():
1114+ compile (ast .Expression (e ), "<test>" , "eval" )
11131115
11141116
11151117class ASTValidatorTests (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments