Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b9b389e

Browse files
committed
Closes #22525: clarify documentation for ast.literal_eval().
1 parent b811a97 commit b9b389e

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

Doc/library/ast.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ and classes for traversing abstract syntax trees:
115115

116116
.. function:: literal_eval(node_or_string)
117117

118-
Safely evaluate an expression node or a string containing a Python
119-
expression. The string or node provided may only consist of the following
120-
Python literal structures: strings, bytes, numbers, tuples, lists, dicts,
121-
sets, booleans, and ``None``.
122-
123-
This can be used for safely evaluating strings containing Python expressions
124-
from untrusted sources without the need to parse the values oneself.
118+
Safely evaluate an expression node or a string containing a Python literal or
119+
container display. The string or node provided may only consist of the
120+
following Python literal structures: strings, bytes, numbers, tuples, lists,
121+
dicts, sets, booleans, and ``None``.
122+
123+
This can be used for safely evaluating strings containing Python values from
124+
untrusted sources without the need to parse the values oneself. It is not
125+
capable of evaluating arbitrarily complex expressions, for example involving
126+
operators or indexing.
125127

126128
.. versionchanged:: 3.2
127129
Now allows bytes and set literals.

0 commit comments

Comments
 (0)