summaryrefslogtreecommitdiffstats
path: root/Lib/ast.py
diff options
context:
space:
mode:
authorBatuhan Taskaya <batuhanosmantaskaya@gmail.com>2020-10-04 00:46:44 (GMT)
committerGitHub <noreply@github.com>2020-10-04 00:46:44 (GMT)
commite799aa8b92c195735f379940acd9925961ad04ec (patch)
treea0308940ce67e0535be861bfc94f3d830bba6734 /Lib/ast.py
parent7f54e563dc150cd670ca8df678437455c3a7f2cd (diff)
downloadcpython-e799aa8b92c195735f379940acd9925961ad04ec.zip
cpython-e799aa8b92c195735f379940acd9925961ad04ec.tar.gz
cpython-e799aa8b92c195735f379940acd9925961ad04ec.tar.bz2
bpo-41887: omit leading spaces/tabs on ast.literal_eval (#22469)
Also document that eval() does this (the same way).
Diffstat (limited to 'Lib/ast.py')
-rw-r--r--Lib/ast.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/ast.py b/Lib/ast.py
index d860917..d8bd337 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -59,7 +59,7 @@ def literal_eval(node_or_string):
sets, booleans, and None.
"""
if isinstance(node_or_string, str):
- node_or_string = parse(node_or_string, mode='eval')
+ node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
if isinstance(node_or_string, Expression):
node_or_string = node_or_string.body
def _raise_malformed_node(node):