From: Georg Brandl Date: Wed, 5 Nov 2014 19:20:28 +0000 (+0100) Subject: Closes #22525: clarify documentation for ast.literal_eval(). X-Git-Tag: v3.5.0a1~517^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b9b389efed16e31d657b047dd2f60817afd820ec;p=python Closes #22525: clarify documentation for ast.literal_eval(). --- diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst index daf28de29e..1ee5110211 100644 --- a/Doc/library/ast.rst +++ b/Doc/library/ast.rst @@ -115,13 +115,15 @@ and classes for traversing abstract syntax trees: .. function:: literal_eval(node_or_string) - Safely evaluate an expression node or a string containing a Python - expression. The string or node provided may only consist of the following - Python literal structures: strings, bytes, numbers, tuples, lists, dicts, - sets, booleans, and ``None``. - - This can be used for safely evaluating strings containing Python expressions - from untrusted sources without the need to parse the values oneself. + Safely evaluate an expression node or a string containing a Python literal or + container display. The string or node provided may only consist of the + following Python literal structures: strings, bytes, numbers, tuples, lists, + dicts, sets, booleans, and ``None``. + + This can be used for safely evaluating strings containing Python values from + untrusted sources without the need to parse the values oneself. It is not + capable of evaluating arbitrarily complex expressions, for example involving + operators or indexing. .. versionchanged:: 3.2 Now allows bytes and set literals.