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 vstinner
Recipients vstinner
Date 2012-04-05.12:09:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1333627782.45.0.741262125731.issue14385@psf.upfronthosting.co.za>
In-reply-to
Content
New version:
 - if __build_class__ is missing, raise a NameError instead of surprising ImportError
 - add tests
 - if PyObject_GetItem on __builtins__ or globals fail, only raise NameError if the exception is a KeyError

Before my patch, a new dict was created for builtins if __builtins__ exists in global but is not a dict. With my patch, the __builtins__ is kept and the type is checked at runtime. If __builtins__ is not a mapping, an exception is raised on lookup in ceval.c.

We may check __builtins__ type in PyFrame_New() using:

PyDict_Check(builtins) || (PyMapping_Check(mapping) && !PyList_Check(mapping) && !PyTuple_Check(mapping))

(PyDict_Check(builtins) is checked first for performance)
History
Date User Action Args
2012-04-05 12:09:42vstinnersetrecipients: + vstinner
2012-04-05 12:09:42vstinnersetmessageid: <1333627782.45.0.741262125731.issue14385@psf.upfronthosting.co.za>
2012-04-05 12:09:41vstinnerlinkissue14385 messages
2012-04-05 12:09:41vstinnercreate