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-03-25.23:59:40
SpamBayes Score 4.5453294e-08
Marked as misclassified No
Message-id <1332719981.64.0.880551106391.issue14385@psf.upfronthosting.co.za>
In-reply-to
Content
With my patch, Python doesn't check __builtins__ type whereas ceval.c replaces any lookup error by a NameError. Example:

$ ./python 
Python 3.3.0a1+ (default:f8d01c8baf6a+, Mar 26 2012, 01:44:48) 
>>> code=compile("print('Hello World!')", "", "exec")
>>> exec(code,{'__builtins__': {'print': print}})
Hello World!
>>> exec(code,{'__builtins__': {}})
NameError: name 'print' is not defined
>>> exec(code,{'__builtins__': 1})
NameError: name 'print' is not defined

It should only replace the current exception by NameError if the current exception is a LookupError.

And my patch on LOAD_GLOBAL is not correct, it does still call PyDict_GetItem. I'm waiting until #14383 is done before writing a new patch.
History
Date User Action Args
2012-03-25 23:59:41vstinnersetrecipients: + vstinner
2012-03-25 23:59:41vstinnersetmessageid: <1332719981.64.0.880551106391.issue14385@psf.upfronthosting.co.za>
2012-03-25 23:59:41vstinnerlinkissue14385 messages
2012-03-25 23:59:40vstinnercreate