bpo-11105: Do not crash when compiling recursive ASTs (GH-20594) · python/cpython@f349124 · GitHub
Skip to content

Commit f349124

Browse files
authored
bpo-11105: Do not crash when compiling recursive ASTs (GH-20594)
When compiling an AST object with a direct / indirect reference cycles, on the conversion phase because of exceeding amount of calls, a segfault was raised. This patch adds recursion guards to places for preventing user inputs to not to crash AST but instead raise a RecursionError.
1 parent f461a7f commit f349124

4 files changed

Lines changed: 840 additions & 4 deletions

File tree

Lib/test/test_ast.py

Lines changed: 14 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
When compiling :class:`ast.AST` objects with recursive references
2+
through :func:`compile`, the interpreter doesn't crash anymore instead
3+
it raises a :exc:`RecursionError`.

Parser/asdl_c.py

Lines changed: 15 additions & 4 deletions

0 commit comments

Comments
 (0)