|
107 | 107 | import java.util.Map;
|
108 | 108 | import java.util.Set;
|
109 | 109 |
|
| 110 | +import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; |
110 | 111 | import com.oracle.graal.python.nodes.util.CannotCastException;
|
111 | 112 | import org.graalvm.nativeimage.ImageInfo;
|
112 | 113 |
|
@@ -850,7 +851,7 @@ Object doAudit(VirtualFrame frame, Object event, Object[] args) {
|
850 | 851 | }
|
851 | 852 | }
|
852 | 853 |
|
853 |
| - @Builtin(name = "audithook", minNumOfPositionalArgs = 1, doc = "addaudithook($module, /, hook)\n" + |
| 854 | + @Builtin(name = "addaudithook", minNumOfPositionalArgs = 1, doc = "addaudithook($module, /, hook)\n" + |
854 | 855 | "--\n" +
|
855 | 856 | "\n" +
|
856 | 857 | "Adds a new audit hook callback.")
|
@@ -1360,7 +1361,7 @@ abstract static class BreakpointHookNode extends PythonBuiltinNode {
|
1360 | 1361 | static final String METH_GET = "get";
|
1361 | 1362 |
|
1362 | 1363 | private String getEnvVar(VirtualFrame frame, PyImportImport importNode, PyObjectGetAttr getAttr, PyObjectCallMethodObjArgs callMethodObjArgs,
|
1363 |
| - CastToJavaStringNode castToJavaStringNode) { |
| 1364 | + CastToJavaStringNode castToJavaStringNode) { |
1364 | 1365 | Object os = importNode.execute(frame, MOD_OS);
|
1365 | 1366 | final Object environ = getAttr.execute(frame, os, ATTR_ENVIRON);
|
1366 | 1367 | Object var = callMethodObjArgs.execute(frame, environ, METH_GET, PYTHONBREAKPOINT);
|
@@ -1579,15 +1580,23 @@ Object setCheckInterval(VirtualFrame frame, @SuppressWarnings("unused") PythonMo
|
1579 | 1580 | "exit status will be one (i.e., failure).")
|
1580 | 1581 | @GenerateNodeFactory
|
1581 | 1582 | abstract static class ExitNode extends PythonBinaryBuiltinNode {
|
1582 |
| - @Specialization(guards = "!isPNone(status)") |
1583 |
| - Object exit(@SuppressWarnings("unused") PythonModule sys, Object status) { |
1584 |
| - throw raiseSystemExit(status); |
1585 |
| - } |
1586 |
| - |
1587 | 1583 | @Specialization
|
1588 | 1584 | @SuppressWarnings("unused")
|
1589 | 1585 | Object exitNoCode(PythonModule sys, PNone status) {
|
1590 | 1586 | throw raiseSystemExit(PNone.NONE);
|
1591 | 1587 | }
|
| 1588 | + |
| 1589 | + @Specialization(guards = "!isPNone(status)") |
| 1590 | + Object exit(VirtualFrame frame, @SuppressWarnings("unused") PythonModule sys, Object status, |
| 1591 | + @Cached TupleBuiltins.GetItemNode getItemNode, |
| 1592 | + @Cached SequenceStorageNodes.LenNode lenNode) { |
| 1593 | + Object code = status; |
| 1594 | + if (status instanceof PTuple) { |
| 1595 | + if (lenNode.execute(((PTuple) status).getSequenceStorage()) == 1) { |
| 1596 | + code = getItemNode.execute(frame, status, 0); |
| 1597 | + } |
| 1598 | + } |
| 1599 | + throw raiseSystemExit(code); |
| 1600 | + } |
1592 | 1601 | }
|
1593 | 1602 | }
|
0 commit comments