bpo-41887: omit leading spaces/tabs on ast.literal_eval (#22469)
Also document that eval() does this (the same way).
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index 755c60f..62138ef 100644
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -1586,6 +1586,9 @@
.. versionchanged:: 3.9
Now supports creating empty sets with ``'set()'``.
+ .. versionchanged:: 3.10
+ For string inputs, leading spaces and tabs are now stripped.
+
.. function:: get_docstring(node, clean=True)
@@ -1820,4 +1823,4 @@
`Parso <https://parso.readthedocs.io>`_ is a Python parser that supports
error recovery and round-trip parsing for different Python versions (in
multiple Python versions). Parso is also able to list multiple syntax errors
- in your python file.
\ No newline at end of file
+ in your python file.
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index c49bb0c..263c52a 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -506,6 +506,9 @@
returns the current global and local dictionary, respectively, which may be
useful to pass around for use by :func:`eval` or :func:`exec`.
+ If the given source is a string, then leading and trailing spaces and tabs
+ are stripped.
+
See :func:`ast.literal_eval` for a function that can safely evaluate strings
with expressions containing only literals.