From 9714fba6d5f6a951f61f7462755976dc3f155dd8 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 9 Mar 2018 12:03:22 -0800 Subject: [PATCH] bpo-32758: Warn that ast.parse() and ast.literal_eval() can segfault the interpreter (GH-5960) (cherry picked from commit 7a7f100eb352d08938ee0f5ba59c18f56dc4a7b5) Co-authored-by: Brett Cannon --- Doc/library/ast.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst index 8d4ae2cc616fa3a..6376f5fe441011b 100644 --- a/Doc/library/ast.rst +++ b/Doc/library/ast.rst @@ -113,6 +113,11 @@ and classes for traversing abstract syntax trees: Parse the source into an AST node. Equivalent to ``compile(source, filename, mode, ast.PyCF_ONLY_AST)``. + .. warning:: + It is possible to crash the Python interpreter with a + sufficiently large/complex string due to stack depth limitations + in Python's AST compiler. + .. function:: literal_eval(node_or_string) @@ -126,6 +131,11 @@ and classes for traversing abstract syntax trees: capable of evaluating arbitrarily complex expressions, for example involving operators or indexing. + .. warning:: + It is possible to crash the Python interpreter with a + sufficiently large/complex string due to stack depth limitations + in Python's AST compiler. + .. versionchanged:: 3.2 Now allows bytes and set literals.