summaryrefslogtreecommitdiffstats
path: root/Doc/library/functions.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-08-07 00:56:22 (GMT)
committerGitHub <noreply@github.com>2019-08-07 00:56:22 (GMT)
commit610a4823cc0a3c2380ad0dfe64ae483ced4e5304 (patch)
tree8aa34d282ee4d562c3edfcbb967c48c972cea634 /Doc/library/functions.rst
parent3e41f3cabb661824a1a197116f7f5ead64eb6ced (diff)
downloadcpython-610a4823cc0a3c2380ad0dfe64ae483ced4e5304.zip
cpython-610a4823cc0a3c2380ad0dfe64ae483ced4e5304.tar.gz
cpython-610a4823cc0a3c2380ad0dfe64ae483ced4e5304.tar.bz2
bpo-37646: Document that eval() cannot access nested scopes (GH-15117)
Diffstat (limited to 'Doc/library/functions.rst')
-rw-r--r--Doc/library/functions.rst16
1 files changed, 10 insertions, 6 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index e146f5a..c225f3d 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -465,12 +465,16 @@ are always available. They are listed here in alphabetical order.
dictionaries as global and local namespace. If the *globals* dictionary is
present and does not contain a value for the key ``__builtins__``, a
reference to the dictionary of the built-in module :mod:`builtins` is
- inserted under that key before *expression* is parsed.
- This means that *expression* normally has full
- access to the standard :mod:`builtins` module and restricted environments are
- propagated. If the *locals* dictionary is omitted it defaults to the *globals*
- dictionary. If both dictionaries are omitted, the expression is executed in the
- environment where :func:`eval` is called. The return value is the result of
+ inserted under that key before *expression* is parsed. This means that
+ *expression* normally has full access to the standard :mod:`builtins`
+ module and restricted environments are propagated. If the *locals*
+ dictionary is omitted it defaults to the *globals* dictionary. If both
+ dictionaries are omitted, the expression is executed with the *globals* and
+ *locals* in the environment where :func:`eval` is called. Note, *eval()*
+ does not have access to the :term:`nested scope`\s (non-locals) in the
+ enclosing environment.
+
+ The return value is the result of
the evaluated expression. Syntax errors are reported as exceptions. Example:
>>> x = 1