[Python-checkins] bpo-32758: Warn that ast.parse() and ast.literal_eval() can segfault the interpreter (GH-5960) (GH-6041)

Brett Cannon webhook-mailer at python.org
Fri Mar 9 15:35:45 EST 2018


https://github.com/python/cpython/commit/f2fffd41b42d88fe36b483852ae33d5a415b7082
commit: f2fffd41b42d88fe36b483852ae33d5a415b7082
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Brett Cannon <brettcannon at users.noreply.github.com>
date: 2018-03-09T12:35:42-08:00
summary:

bpo-32758: Warn that ast.parse() and ast.literal_eval() can segfault the interpreter (GH-5960) (GH-6041)

(cherry picked from commit 7a7f100eb352d08938ee0f5ba59c18f56dc4a7b5)

Co-authored-by: Brett Cannon <brettcannon at users.noreply.github.com>

files:
M Doc/library/ast.rst

diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index b7f610ba8b2a..a75a6afbf2d7 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.
 



More information about the Python-checkins mailing list