|
91 | 91 | import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.UnicodeFromWcharNode;
|
92 | 92 | import com.oracle.graal.python.builtins.objects.cext.common.CExtToNativeNode;
|
93 | 93 | import com.oracle.graal.python.builtins.objects.cext.common.ConversionNodeSupplier;
|
| 94 | +import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions.GraalHPyContextFunction; |
94 | 95 | import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsContextNode;
|
95 | 96 | import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsHandleNode;
|
96 | 97 | import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsPythonObjectNode;
|
@@ -340,13 +341,17 @@ Object execute(Object[] arguments,
|
340 | 341 |
|
341 | 342 | // process HPy methods
|
342 | 343 | Object moduleDefines = callGetterNode.call(context, GRAAL_HPY_MODULE_GET_DEFINES, moduleDef);
|
343 |
| - if (!ptrLib.hasArrayElements(moduleDefines)) { |
344 |
| - CompilerDirectives.transferToInterpreterAndInvalidate(); |
345 |
| - throw raiseNode.raise(PythonBuiltinClassType.SystemError, "field 'defines' did not return an array"); |
346 |
| - } |
347 |
| - |
348 | 344 | try {
|
349 |
| - long nModuleDefines = ptrLib.getArraySize(moduleDefines); |
| 345 | + long nModuleDefines; |
| 346 | + if (ptrLib.isNull(moduleDefines)) { |
| 347 | + nModuleDefines = 0; |
| 348 | + } else if (!ptrLib.hasArrayElements(moduleDefines)) { |
| 349 | + CompilerDirectives.transferToInterpreterAndInvalidate(); |
| 350 | + throw raiseNode.raise(PythonBuiltinClassType.SystemError, "field 'defines' did not return an array"); |
| 351 | + } else { |
| 352 | + nModuleDefines = ptrLib.getArraySize(moduleDefines); |
| 353 | + } |
| 354 | + |
350 | 355 | for (long i = 0; i < nModuleDefines; i++) {
|
351 | 356 | Object moduleDefine = ptrLib.readArrayElement(moduleDefines, i);
|
352 | 357 | int kind = castToJavaIntNode.execute(callGetterNode.call(context, GRAAL_HPY_DEF_GET_KIND, moduleDefine));
|
|
0 commit comments