Skip to content

Commit b316c44

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

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
@@ -113,6 +113,11 @@ and classes for traversing abstract syntax trees:
113113
Parse the source into an AST node. Equivalent to ``compile(source,
114114
filename, mode, ast.PyCF_ONLY_AST)``.
115115

116+
.. warning::
117+
It is possible to crash the Python interpreter with a
118+
sufficiently large/complex string due to stack depth limitations
119+
in Python's AST compiler.
120+
116121

117122
.. function:: literal_eval(node_or_string)
118123

@@ -126,6 +131,11 @@ and classes for traversing abstract syntax trees:
126131
capable of evaluating arbitrarily complex expressions, for example involving
127132
operators or indexing.
128133

134+
.. warning::
135+
It is possible to crash the Python interpreter with a
136+
sufficiently large/complex string due to stack depth limitations
137+
in Python's AST compiler.
138+
129139
.. versionchanged:: 3.2
130140
Now allows bytes and set literals.
131141

0 commit comments

Comments
 (0)