@@ -478,14 +478,15 @@ are always available. They are listed here in alphabetical order.
478
478
dictionaries as global and local namespace. If the *globals * dictionary is
479
479
present and does not contain a value for the key ``__builtins__ ``, a
480
480
reference to the dictionary of the built-in module :mod: `builtins ` is
481
- inserted under that key before *expression * is parsed. This means that
482
- *expression * normally has full access to the standard :mod: `builtins `
483
- module and restricted environments are propagated. If the *locals *
484
- dictionary is omitted it defaults to the *globals * dictionary. If both
485
- dictionaries are omitted, the expression is executed with the *globals * and
486
- *locals * in the environment where :func: `eval ` is called. Note, *eval() *
487
- does not have access to the :term: `nested scopes <nested scope> ` (non-locals) in the
488
- enclosing environment.
481
+ inserted under that key before *expression * is parsed. That way you can
482
+ control what builtins are available to the executed code by inserting your
483
+ own ``__builtins__ `` dictionary into *globals * before passing it to
484
+ :func: `eval `. If the *locals * dictionary is omitted it defaults to the
485
+ *globals * dictionary. If both dictionaries are omitted, the expression is
486
+ executed with the *globals * and *locals * in the environment where
487
+ :func: `eval ` is called. Note, *eval() * does not have access to the
488
+ :term: `nested scopes <nested scope> ` (non-locals) in the enclosing
489
+ environment.
489
490
490
491
The return value is the result of
491
492
the evaluated expression. Syntax errors are reported as exceptions. Example:
0 commit comments