Skip to content

Commit db98fd6

Browse files
committed
Fix: check result of exec function as it would be a pointer
1 parent 6a1ca8f commit db98fd6

File tree

1 file changed

+8
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

1 file changed

+8
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3818,7 +3818,14 @@ static int doGeneric(CApiContext capiContext, PythonModule module, Object module
38183818
Object execFunction = interopLib.readMember(slotDefinition, MODULEDEF_VALUE);
38193819
Object result = interopLib.execute(execFunction, moduleToNativeNode.execute(capiContext, module));
38203820
int iResult = interopLib.asInt(result);
3821-
DefaultCheckFunctionResultNode.checkFunctionResult(mName, iResult != 0, true, language, capiContext.getContext(), raiseNode, factory,
3821+
/*
3822+
* It's a bit counterintuitive that we use 'isPrimitiveValue = false'
3823+
* but the function's return value is actually not a result but a status
3824+
* code. So, if the status code is '!=0' we know that an error occurred
3825+
* and won't ignore this if no error is set. This is then the same
3826+
* behaviour if we would have a pointer return type and got 'NULL'.
3827+
*/
3828+
DefaultCheckFunctionResultNode.checkFunctionResult(mName, iResult != 0, false, language, capiContext.getContext(), raiseNode, factory,
38223829
EXECUTION_FAILED_WITHOUT_EXCEPTION, EXECUTION_RAISED_EXCEPTION);
38233830
break;
38243831
default:

0 commit comments

Comments
 (0)