Skip to content

Commit dedb99a

Browse files
AWhetterbrettcannon
authored andcommitted
bpo-32758: Warn that ast.parse() and ast.literal_eval() can segfault the interpreter (GH-5960) (GH-16565)
(cherry picked from commit 7a7f100) Co-authored-by: Brett Cannon <[email protected]>
1 parent 8eb27cc commit dedb99a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Doc/library/ast.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ and classes for traversing abstract syntax trees:
129129
Parse the source into an AST node. Equivalent to ``compile(source,
130130
filename, mode, ast.PyCF_ONLY_AST)``.
131131

132+
.. warning::
133+
It is possible to crash the Python interpreter with a
134+
sufficiently large/complex string due to stack depth limitations
135+
in Python's AST compiler.
136+
132137

133138
.. function:: literal_eval(node_or_string)
134139

@@ -142,6 +147,11 @@ and classes for traversing abstract syntax trees:
142147
capable of evaluating arbitrarily complex expressions, for example involving
143148
operators or indexing.
144149

150+
.. warning::
151+
It is possible to crash the Python interpreter with a
152+
sufficiently large/complex string due to stack depth limitations
153+
in Python's AST compiler.
154+
145155

146156
.. function:: get_docstring(node, clean=True)
147157

0 commit comments

Comments
 (0)