diff options
author | Gregory P. Smith <greg@krypto.org> | 2022-10-01 17:55:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-01 17:55:40 -0700 |
commit | 8baef8ae367041a5cfefb40b19c7b87e9bcb56a2 (patch) | |
tree | cd2e3f7b254d9bc34d5d66657fe821c96853b266 /Lib/ast.py | |
parent | bd7d0e875e6955dd69cde18a034e59a75b8b4d00 (diff) | |
download | cpython-8baef8ae367041a5cfefb40b19c7b87e9bcb56a2.tar.gz cpython-8baef8ae367041a5cfefb40b19c7b87e9bcb56a2.zip |
gh-95588: Drop the safety claim from `ast.literal_eval` docs. (#95919)
It was never really safe and this claim conflicts directly with the big warning in the docs about it being able to crash the interpreter.
Diffstat (limited to 'Lib/ast.py')
-rw-r--r-- | Lib/ast.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/ast.py b/Lib/ast.py index 8adb61fed45..1a94e9368c1 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -54,10 +54,12 @@ def parse(source, filename='<unknown>', mode='exec', *, def literal_eval(node_or_string): """ - Safely evaluate an expression node or a string containing a Python + Evaluate an expression node or a string containing only 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. + + Caution: A complex expression can overflow the C stack and cause a crash. """ if isinstance(node_or_string, str): node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval') |