消息 [156791]
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. |
|
| 日期 |
用户 |
动作 |
参数 |
| 2012-03-25 23:59:41 | vstinner | 修改 | recipients:
+ vstinner |
| 2012-03-25 23:59:41 | vstinner | 修改 | messageid: <1332719981.64.0.880551106391.issue14385@psf.upfronthosting.co.za> |
| 2012-03-25 23:59:41 | vstinner | 链接 | issue14385 messages |
| 2012-03-25 23:59:40 | vstinner | 创建 | |
|