Skip to content

Commit e7d05ad

Browse files
committed
Avoid returning Java null from md_state getter
1 parent 5637172 commit e7d05ad

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSlotBuiltins.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,9 @@ static Object get(Object object,
590590
@CApiBuiltin(ret = Pointer, args = {PyModuleObject}, call = Ignored)
591591
abstract static class Py_get_PyModuleObject_md_state extends CApiUnaryBuiltinNode {
592592
@Specialization
593-
static Object get(PythonModule object) {
594-
return object.getNativeModuleState();
593+
static Object get(PythonModule object,
594+
@Bind Node inliningTarget) {
595+
return object.getNativeModuleState() != null ? object.getNativeModuleState() : PythonContext.get(inliningTarget).getNativeNull();
595596
}
596597
}
597598

@@ -743,7 +744,7 @@ static Object get(PString object,
743744
object.setNativeCharSequence(nativeSequence);
744745
/*
745746
* Create a native sequence storage to manage the lifetime of the native memory.
746-
*
747+
*
747748
* TODO it would be nicer if the native char sequence could manage its own memory
748749
*/
749750
writeAttribute.execute(inliningTarget, object, NATIVE_STORAGE, NativeByteSequenceStorage.create(ptr, byteLength, byteLength, true));

0 commit comments

Comments
 (0)