Skip to content

Commit 7454a6b

Browse files
committed
Reset exception state only if necessary.
1 parent 19dd21e commit 7454a6b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,16 +562,18 @@ Object doGeneric(String name, Object result) {
562562
private void checkFunctionResult(String name, boolean isNull) {
563563
PythonContext context = getContext();
564564
PException currentException = context.getCurrentException();
565-
// consume exception
566-
context.setCurrentException(null);
567565
boolean errOccurred = currentException != null;
568566
if (isNull) {
567+
// consume exception
568+
context.setCurrentException(null);
569569
if (!errOccurred) {
570570
throw raise(PythonErrorType.SystemError, "%s returned NULL without setting an error", name);
571571
} else {
572572
throw currentException;
573573
}
574574
} else if (errOccurred) {
575+
// consume exception
576+
context.setCurrentException(null);
575577
throw raise(PythonErrorType.SystemError, "%s returned a result with an error set", name);
576578
}
577579
}

0 commit comments

Comments
 (0)