Commit a8b89fed authored by Georg Brandl's avatar Georg Brandl

Closes #22525: clarify documentation for ast.literal_eval().

parent b6e7c7e9
...@@ -115,13 +115,15 @@ and classes for traversing abstract syntax trees: ...@@ -115,13 +115,15 @@ and classes for traversing abstract syntax trees:
.. function:: literal_eval(node_or_string) .. function:: literal_eval(node_or_string)
Safely evaluate an expression node or a string containing a Python Safely evaluate an expression node or a string containing a Python literal or
expression. The string or node provided may only consist of the following container display. The string or node provided may only consist of the
Python literal structures: strings, bytes, numbers, tuples, lists, dicts, following Python literal structures: strings, bytes, numbers, tuples, lists,
sets, booleans, and ``None``. dicts, sets, booleans, and ``None``.
This can be used for safely evaluating strings containing Python expressions This can be used for safely evaluating strings containing Python values from
from untrusted sources without the need to parse the values oneself. 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 .. versionchanged:: 3.2
Now allows bytes and set literals. Now allows bytes and set literals.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment