Skip to content

__file__ value is lost when using different ScriptEngine instances in the same thread (v2.7.4b1) #327

Open

Description

@hinerm

Hello,

When I run this code:

ScriptEngineManager mgr = new ScriptEngineManager();
final String script = "print __file__\n";
for (int i=0; i<5; i++) {
	ScriptEngine pyEngine = mgr.getEngineByName("jython");
	pyEngine.put(ScriptEngine.FILENAME, "hello" + i +".py");
	pyEngine.eval(script);
}

On any execution after the first I get errors with __file__ being undefined. This does not happen if I use a single ScriptEngine instance, or if each instance runs in a separate thread.

I can see that the interpreter gets the __file__ value appropriately, but then it is lost here.

Is there a contract that would explain this behavior or is it a bug?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions