[docs] [issue26363] __builtins__ propagation is misleading described in exec and eval documentation
Julien Palard
report at bugs.python.org
Sat Nov 26 09:35:00 EST 2016
Julien Palard added the comment:
Hi Xavier, thanks for reporting,
Your first point is right, the implementation being:
if (PyDict_GetItemString(globals, "__builtins__") == NULL) {
if (PyDict_SetItemString(globals, "__builtins__",
PyEval_GetBuiltins()) != 0)
return NULL;
}
See proposed diff.
For the second point, it looks right to me in the documentation, literally: "A reference to the dictionary of the builtin module builtins is inserted", so:
It's a dict:
>>> exec('print(type(globals()["__builtins__"]))', {})
<class 'dict'>
It's the reference to the dict of the builtins module:
>>> exec('globals()["__builtins__"]["len"] = "foo"', {})
>>> len
'foo'
If you still think there's inconsistencies, please provide some code to reproduce it.
----------
keywords: +patch
Added file: http://bugs.python.org/file45652/issue26363.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26363>
_______________________________________
More information about the docs
mailing list