diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_ast.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 249e4bf..6a6f06c 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -1098,6 +1098,20 @@ Module( exec(code, ns) self.assertIn('sleep', ns) + def test_recursion_direct(self): + e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0) + e.operand = e + with self.assertRaises(RecursionError): + compile(ast.Expression(e), "<test>", "eval") + + def test_recursion_indirect(self): + e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0) + f = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0) + e.operand = f + f.operand = e + with self.assertRaises(RecursionError): + compile(ast.Expression(e), "<test>", "eval") + class ASTValidatorTests(unittest.TestCase): |