Skip to content

Commit df12a88

Browse files
committed
set the ExecutableList correctly when the commandline sets an Executable
1 parent e5e69df commit df12a88

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,15 @@ protected void launch(Builder contextBuilder) {
394394
unbufferedIO = unbufferedIO || System.getenv("PYTHONUNBUFFERED") != null;
395395
}
396396

397-
// The unlikely separator is used because options need to be strings. See
398-
// PythonOptions.getExecutableList()
399-
contextBuilder.option("python.ExecutableList", String.join("🏆", getExecutableList()));
400-
setContextOptionIfUnset(contextBuilder, "python.Executable", getExecutable());
397+
String executable = getContextOptionIfSetViaCommandLine("python.Executable");
398+
if (executable != null) {
399+
contextBuilder.option("python.ExecutableList", executable);
400+
} else {
401+
contextBuilder.option("python.Executable", getExecutable());
402+
// The unlikely separator is used because options need to be
403+
// strings. See PythonOptions.getExecutableList()
404+
contextBuilder.option("python.ExecutableList", String.join("🏆", getExecutableList()));
405+
}
401406

402407
// setting this to make sure our TopLevelExceptionHandler calls the excepthook
403408
// to print Python exceptions
@@ -471,16 +476,21 @@ protected void launch(Builder contextBuilder) {
471476
System.exit(rc);
472477
}
473478

474-
private void setContextOptionIfUnset(Builder contextBuilder, String key, String value) {
479+
private String getContextOptionIfSetViaCommandLine(String key) {
475480
if (System.getProperty("polyglot." + key) != null) {
476-
return;
481+
return System.getProperty("polyglot." + key);
477482
}
478483
for (String f : givenArguments) {
479484
if (f.startsWith("--" + key)) {
480-
return;
485+
String[] splits = f.split("=", 2);
486+
if (splits.length > 1) {
487+
return splits[1];
488+
} else {
489+
return "true";
490+
}
481491
}
482492
}
483-
contextBuilder.option(key, value);
493+
return null;
484494
}
485495

486496
private static void printFileNotFoundException(NoSuchFileException e) {

0 commit comments

Comments
 (0)