Skip to content

Commit fdc5f7a

Browse files
committed
[GR-45642] Missing symbols in C extensions should lead to an ImportError, not a SystemError
(cherry picked from commit ff3caf8)
1 parent b920227 commit fdc5f7a

File tree

1 file changed

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

1 file changed

+10
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtContext.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
import com.oracle.truffle.api.CompilerDirectives.ValueType;
8181
import com.oracle.truffle.api.TruffleLanguage.Env;
8282
import com.oracle.truffle.api.TruffleLogger;
83+
import com.oracle.truffle.api.exception.AbstractTruffleException;
8384
import com.oracle.truffle.api.interop.ArityException;
8485
import com.oracle.truffle.api.interop.InteropLibrary;
8586
import com.oracle.truffle.api.interop.UnknownIdentifierException;
@@ -351,7 +352,15 @@ public static Object loadCExtModule(Node location, PythonContext context, Module
351352
if (PythonOptions.UsePanama.getValue(context.getEnv().getOptions())) {
352353
loadExpr = "with panama " + loadExpr;
353354
}
354-
library = GraalHPyContext.evalNFI(context, loadExpr, "load " + spec.name);
355+
try {
356+
library = GraalHPyContext.evalNFI(context, loadExpr, "load " + spec.name);
357+
} catch (AbstractTruffleException e) {
358+
if (e instanceof PException pe) {
359+
throw pe;
360+
} else {
361+
throw new ImportException(CExtContext.wrapJavaException(e, location), spec.name, spec.path, ErrorMessages.CANNOT_LOAD_M, spec.path, e);
362+
}
363+
}
355364
}
356365
} else {
357366
cApiContext.supportsNativeBackend = false;

0 commit comments

Comments
 (0)