Berker Peksag <berker.pek...@gmail.com> added the comment:

Thank you for the report, Xavier.

This is a duplicate of issue 22057.

PR 8812 clarifies the behavior when a dictionary without a "__builtins__" key 
is passed as *globals* to eval(). I think that makes the opposite case much 
easier to understand.

>>> eval("print(spam)", {'__builtins__': {'spam': 'eggs'}})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in <module>
NameError: name 'print' is not defined

>>> eval("print(spam)", {'__builtins__': {'spam': 'eggs', 'print': print}})
eggs

Also, I never needed to pass a dictionary with a "__builtins__" key to eval() 
before, so I don't think it's an important detail to document.

----------
nosy: +berker.peksag
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> The doc say all globals are copied on eval(), but only 
__builtins__ is copied
type:  -> behavior
versions: +Python 3.8 -Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue26363>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to