This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mdk
Recipients docs@python, mdk, xcombelle
Date 2016-11-26.14:35:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1480170900.75.0.0714267606463.issue26363@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-11-26 14:35:00mdksetrecipients: + mdk, docs@python, xcombelle
2016-11-26 14:35:00mdksetmessageid: <1480170900.75.0.0714267606463.issue26363@psf.upfronthosting.co.za>
2016-11-26 14:35:00mdklinkissue26363 messages
2016-11-26 14:35:00mdkcreate