Skip to content

Commit 7a7f100

Browse files
authored
bpo-32758: Warn that ast.parse() and ast.literal_eval() can segfault the interpreter (GH-5960)
1 parent 83d7062 commit 7a7f100

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Doc/library/ast.rst

+10
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)