Message12832

Author jeff.allen
Recipients alexgobbo, jeff.allen, zyasoft
Date 2019-12-13.23:25:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576279556.73.0.24057865266.issue2846@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-12-13 23:25:56jeff.allensetmessageid: <1576279556.73.0.24057865266.issue2846@roundup.psfhosted.org>
2019-12-13 23:25:56jeff.allensetrecipients: + jeff.allen, zyasoft, alexgobbo
2019-12-13 23:25:56jeff.allenlinkissue2846 messages
2019-12-13 23:25:56jeff.allencreate