Message12832
Ah, I see. It's not that we set __name__ to this surprising value. Rather, __name__ is resolved by look-up in locals, globals and builtins, and found in the last.
The difficulty is to be sure of the intent of the design. It looks like ScriptEngine.eval() is the rough equivalent of the exec statement with a user-supplied dictionary (CPython 2.7.16):
>>> exec "print globals().keys()" in {}
['__builtins__']
Jython 2.7.2b3:
>>> from javax.script import ScriptEngineManager
>>> engine = ScriptEngineManager().getEngineByName("python")
>>> engine.eval("print globals().keys()")
['__builtins__']
You're evidently expecting it to be more like executing a file using the python command. Hard to say who's right. |
|
Date |
User |
Action |
Args |
2019-12-13 23:25:56 | jeff.allen | set | messageid: <1576279556.73.0.24057865266.issue2846@roundup.psfhosted.org> |
2019-12-13 23:25:56 | jeff.allen | set | recipients:
+ jeff.allen, zyasoft, alexgobbo |
2019-12-13 23:25:56 | jeff.allen | link | issue2846 messages |
2019-12-13 23:25:56 | jeff.allen | create | |
|