Skip to content

Commit a085ae5

Browse files
committed
Don't return 1 on error in REPL
1 parent 41e381f commit a085ae5

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,6 @@ private static ConsoleHandler createConsoleHandler(InputStream inStream, OutputS
11921192
* exiting. So,in either case, we never return.
11931193
*/
11941194
private int readEvalPrint(Context context, ConsoleHandler consoleHandler, Value sysModule) {
1195-
int lastStatus = 0;
11961195
try {
11971196
Value hook = null;
11981197
try {
@@ -1220,7 +1219,6 @@ private int readEvalPrint(Context context, ConsoleHandler consoleHandler, Value
12201219
String ps2 = null;
12211220
StringBuilder sb = new StringBuilder(input).append('\n');
12221221
while (true) { // processing subsequent lines while input is incomplete
1223-
lastStatus = 0;
12241222
try {
12251223
context.eval(Source.newBuilder(getLanguageId(), sb.toString(), "<stdin>").interactive(true).buildLiteral());
12261224
} catch (PolyglotException e) {
@@ -1280,10 +1278,6 @@ private int readEvalPrint(Context context, ConsoleHandler consoleHandler, Value
12801278
* system may be broken
12811279
*/
12821280
System.err.println("An internal error occurred, continue at your own risk");
1283-
lastStatus = 1;
1284-
} else {
1285-
// drop through to continue REPL and remember last eval was an error
1286-
lastStatus = 1;
12871281
}
12881282
}
12891283
break;
@@ -1295,15 +1289,15 @@ private int readEvalPrint(Context context, ConsoleHandler consoleHandler, Value
12951289
} catch (PolyglotException e2) {
12961290
if (e2.isExit()) {
12971291
// don't use the exit code from the PolyglotException
1298-
return lastStatus;
1292+
return 0;
12991293
} else if (e2.isCancelled()) {
13001294
continue;
13011295
}
13021296
throw new RuntimeException("error while calling exit", e);
13031297
}
13041298
}
13051299
System.out.println();
1306-
return lastStatus;
1300+
return 0;
13071301
} catch (UserInterruptException e) {
13081302
// interrupted by ctrl-c
13091303
}

0 commit comments

Comments
 (0)