Skip to content

Commit e7f23a4

Browse files
committed
Fix: incorrect function result handling
1 parent 187a26d commit e7f23a4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,16 +711,17 @@ Object doNullHandle(GraalHPyContext nativeContext, String name, GraalHPyHandle h
711711
@Shared("fact") @Cached PythonObjectFactory factory,
712712
@Shared("raiseNode") @Cached PRaiseNode raiseNode) {
713713
checkFunctionResult(name, true, nativeContext, raiseNode, factory, language);
714-
return handle;
714+
throw CompilerDirectives.shouldNotReachHere("an exception should have been thrown");
715715
}
716716

717717
@Specialization(guards = "!isNullHandle(nativeContext, handle)", replaces = "doNullHandle")
718718
Object doNonNullHandle(GraalHPyContext nativeContext, String name, @SuppressWarnings("unused") GraalHPyHandle handle,
719+
@Exclusive @Cached HPyAsPythonObjectNode asPythonObjectNode,
719720
@Shared("language") @CachedLanguage PythonLanguage language,
720721
@Shared("fact") @Cached PythonObjectFactory factory,
721722
@Shared("raiseNode") @Cached PRaiseNode raiseNode) {
722723
checkFunctionResult(name, false, nativeContext, raiseNode, factory, language);
723-
throw CompilerDirectives.shouldNotReachHere("an exception should have been thrown");
724+
return asPythonObjectNode.execute(nativeContext, handle);
724725
}
725726

726727
@Specialization(replaces = {"doIntegerNull", "doNonNullHandle"})

0 commit comments

Comments
 (0)