Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hinerm opened this issue May 2, 2024 · 0 comments

Comments

@hinerm
Copy link

hinerm commented May 2, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant