Skip to content

Commit 8b7bdc2

Browse files
committed
SystemExitBuiltins: set code to None when not specified but set the process return code to 0 if the code is set to None
1 parent 01c89d2 commit 8b7bdc2

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,7 @@ Object exit(@SuppressWarnings("unused") PythonModule sys, Object status) {
15811581
@Specialization
15821582
@SuppressWarnings("unused")
15831583
Object exitNoCode(PythonModule sys, PNone status) {
1584-
throw raiseSystemExit(0);
1584+
throw raiseSystemExit(PNone.NONE);
15851585
}
15861586
}
15871587
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SystemExitBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public abstract static class InitNode extends PythonBuiltinNode {
105105
@Specialization
106106
Object initNoArgs(PBaseException self, Object[] args,
107107
@Cached BaseExceptionBuiltins.BaseExceptionInitNode baseExceptionInitNode) {
108-
self.setData(SystemExitData.create(factory(), args));
109108
baseExceptionInitNode.execute(self, args);
109+
self.setData(SystemExitData.create(factory(), args));
110110
return PNone.NONE;
111111
}
112112
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/control/TopLevelExceptionHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ private static int getExitCode(PBaseException pythonException) throws CannotCast
253253
int exitcode = 0;
254254
if (data instanceof SystemExitBuiltins.SystemExitData) {
255255
final Object code = ((SystemExitBuiltins.SystemExitData) data).getCode();
256-
exitcode = (int) CastToJavaLongLossyNode.getUncached().execute(code);
256+
if (code != PNone.NONE) {
257+
exitcode = (int) CastToJavaLongLossyNode.getUncached().execute(code);
258+
}
257259
}
258260
return exitcode;
259261
}

0 commit comments

Comments
 (0)