Skip to content

Commit 59dddfa

Browse files
committed
Save and restore current exception before calling native function.
1 parent 5943b13 commit 59dddfa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,11 @@ public Object execute(VirtualFrame frame) {
611611
arguments[i] = toSulongNode.execute(frameArgs[i + PArguments.USER_ARGUMENTS_OFFSET]);
612612
}
613613
}
614-
return fromNative(asPythonObjectNode.execute(checkFunctionResult(getContext(), isNullNode, name, ForeignAccess.sendExecute(executeNode, fun, arguments))));
614+
// save current exception state
615+
PException exceptionState = getContext().getCurrentException();
616+
Object result = fromNative(asPythonObjectNode.execute(checkFunctionResult(getContext(), isNullNode, name, ForeignAccess.sendExecute(executeNode, fun, arguments))));
617+
getContext().setCurrentException(exceptionState);
618+
return result;
615619
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) {
616620
CompilerDirectives.transferToInterpreter();
617621
throw new RuntimeException(e.toString());

0 commit comments

Comments
 (0)