Skip to content

Commit 9e1bed4

Browse files
committed
Raise Python exceptions if ctypes exec fails
1 parent 4678fff commit 9e1bed4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
import com.oracle.graal.python.lib.PyNumberAsSizeNode;
144144
import com.oracle.graal.python.lib.PyObjectHashNode;
145145
import com.oracle.graal.python.lib.PyObjectHashNodeGen;
146+
import com.oracle.graal.python.nodes.PConstructAndRaiseNode;
146147
import com.oracle.graal.python.nodes.PGuards;
147148
import com.oracle.graal.python.nodes.PNodeWithRaise;
148149
import com.oracle.graal.python.nodes.PRaiseNode;
@@ -269,9 +270,12 @@ public void postInitialize(Python3Core core) {
269270
CApiContext cApiContext = CApiContext.ensureCapiWasLoaded(null, context, T_EMPTY_STRING, T_EMPTY_STRING);
270271
handle = new DLHandler(cApiContext.getLLVMLibrary(), 0, J_EMPTY_STRING, true);
271272
setCtypeLLVMHelpers(this, context, handle);
272-
} catch (IOException | ImportException | ApiInitException e) {
273-
// TODO(fa): properly handle errors
274-
throw CompilerDirectives.shouldNotReachHere();
273+
} catch (ApiInitException e) {
274+
throw e.reraise(PConstructAndRaiseNode.getUncached(), null);
275+
} catch (ImportException e) {
276+
throw e.reraise(PConstructAndRaiseNode.getUncached(), null);
277+
} catch (IOException e) {
278+
throw PConstructAndRaiseNode.getUncached().raiseOSError(null, e, EqualNode.getUncached());
275279
}
276280
}
277281
NativeFunction memmove = MemMoveFunction.create(handle, context);

0 commit comments

Comments
 (0)