Skip to content

Commit 16e87b8

Browse files
committed
print instruments warning from launch() method, instead of preprocessArguments which can be called more than once,
1 parent fe26d12 commit 16e87b8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public static void main(String[] args) {
104104

105105
boolean useASTInterpreter = false;
106106

107+
private String toolInstrumentWarning = null;
108+
107109
protected static void setStartupTime() {
108110
if (GraalPythonMain.startupNanoTime == -1) {
109111
GraalPythonMain.startupNanoTime = System.nanoTime();
@@ -124,7 +126,6 @@ protected List<String> preprocessArguments(List<String> givenArgs, Map<String, S
124126
List<String> subprocessArgs = new ArrayList<>();
125127
programArgs = new ArrayList<>();
126128
boolean posixBackendSpecified = false;
127-
boolean toolInstrumentWarning = true;
128129
for (Iterator<String> argumentIterator = arguments.iterator(); argumentIterator.hasNext();) {
129130
String arg = argumentIterator.next();
130131
if (arg.startsWith("-")) {
@@ -203,10 +204,7 @@ protected List<String> preprocessArguments(List<String> givenArgs, Map<String, S
203204
if (argStartsWith(arg, "--agentscript", "--coverage", "--cpusampler", "--cputracer", "--dap",
204205
"--heap.", "--heapmonitor", "--insight", "--inspect", "--lsp", "--memtracer", "--sandbox.")) {
205206
useASTInterpreter = true;
206-
if (toolInstrumentWarning) {
207-
toolInstrumentWarning = false;
208-
System.out.println("WARNING: Switching to AST interpreter due to instruments option " + arg);
209-
}
207+
toolInstrumentWarning = "WARNING: Switching to AST interpreter due to instruments option " + arg;
210208
} else if (arg.startsWith("--llvm.") ||
211209
matchesPythonOption(arg, "CoreHome") ||
212210
matchesPythonOption(arg, "StdLibHome") ||
@@ -620,6 +618,10 @@ protected void launch(Builder contextBuilder) {
620618
contextBuilder.option("python.PyCachePrefix", "/dev/null");
621619
contextBuilder.option("python.EnableBytecodeInterpreter", "false");
622620
contextBuilder.option("python.DisableFrozenModules", "true");
621+
if (toolInstrumentWarning != null) {
622+
System.out.println(toolInstrumentWarning);
623+
toolInstrumentWarning = null;
624+
}
623625
} else {
624626
contextBuilder.option("python.DontWriteBytecodeFlag", Boolean.toString(dontWriteBytecode));
625627
if (cachePrefix != null) {

0 commit comments

Comments
 (0)