Skip to content

Commit faaadb5

Browse files
committed
only raise ImportError when loading native libraries if we actually fail to load through sulong (it might be managed)
1 parent 6c9afff commit faaadb5

File tree

1 file changed

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

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -938,10 +938,6 @@ public static boolean isPointerToPrimitive(LLVMType llvmType) {
938938
@TruffleBoundary
939939
public static CApiContext ensureCapiWasLoaded(Node node, PythonContext context, String name, String path) throws IOException, ImportException, ApiInitException {
940940
if (!context.hasCApiContext()) {
941-
if (!context.getEnv().isNativeAccessAllowed()) {
942-
throw new ImportException(null, name, path, ErrorMessages.NATIVE_ACCESS_NOT_ALLOWED);
943-
}
944-
945941
Env env = context.getEnv();
946942

947943
String libPythonName = "libpython" + context.getSoAbi();
@@ -968,6 +964,9 @@ public static CApiContext ensureCapiWasLoaded(Node node, PythonContext context,
968964
*/
969965
throw e.getExceptionForReraise();
970966
} catch (RuntimeException e) {
967+
if (!context.getEnv().isNativeAccessAllowed()) {
968+
throw new ImportException(null, name, path, ErrorMessages.NATIVE_ACCESS_NOT_ALLOWED);
969+
}
971970
throw new ApiInitException(wrapJavaException(e, node), name, ErrorMessages.CAPI_LOAD_ERROR, capiFile.getAbsoluteFile().getPath());
972971
}
973972
}

0 commit comments

Comments
 (0)