Author amak
Recipients amak, yocaba
Date 2016-08-27.13:15:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> In the contructor of the PyScriptEngine a new instance of PythonInterpreter
> is created with the help of its static factory method
> threadLocalStateInterpreter(). The method passes null for the PySystemState
> to the constructor of PythonInterpreter. In the case of a null PySystemState
> the PythonInterpreter constructor instantiates the PySystemState with
> Py.getSystemState(). As I don't see any changes to the PySystemState field
> later on in the class, I'd assume that all PyScriptEngine instances share
> the same PySystemState no matter if a new ScriptContext instance is set to
> the engine or passed to the eval method or not. But I simply might miss
> something here.

I don't think you're missing anything, I think you're exactly right.

The PyScriptEngine does indeed create every PythonInterpreter with a shared PySystemState.

ScriptContext is supposed to allow you to separate the input and output of every PyScriptEngine.eval call. But the current PyScriptEngine does not implement this properly.

Instead, when you give it a ScriptContext, it takes the output handler of the ScriptContext and sets the output handler of the embedded PythonInterpreter to that handler.

The implementation of PythonInterpreter.setOut then sets the output handler of its PySystemState to that output handler.

So the fact that all PythonInterpreter objects created by PyScriptEngine share the same PySystemState means that you cannot, using PyScriptEngine, separate the output in the way that you require.

I'd call that a bug in jython's JSR 223 implementation.
Date User Action Args
2016-08-27 13:15:28amaksetmessageid: <>
2016-08-27 13:15:28amaksetrecipients: + amak, yocaba
2016-08-27 13:15:28amaklinkissue2513 messages
2016-08-27 13:15:27amakcreate