Skip to content

Commit a25bcb2

Browse files
fangerertimfel
authored andcommitted
Convert Java OutOfMemoryError to Python MemoryError
1 parent 2952f59 commit a25bcb2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
*/
4141
package com.oracle.graal.python.builtins.modules.cext;
4242

43+
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.MemoryError;
4344
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.NotImplementedError;
4445
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.RecursionError;
4546
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError;
@@ -259,6 +260,10 @@ public static PException checkThrowableBeforeNative(Throwable t, String where1,
259260
PException pe = ExceptionUtils.wrapJavaException(soe, null, newException);
260261
throw pe;
261262
}
263+
if (t instanceof OutOfMemoryError oome) {
264+
PBaseException newException = PythonContext.get(null).factory().createBaseException(MemoryError);
265+
throw ExceptionUtils.wrapJavaException(oome, null, newException);
266+
}
262267
// everything else: log and convert to PException (SystemError)
263268
CompilerDirectives.transferToInterpreter();
264269
PNodeWithContext.printStack();

0 commit comments

Comments
 (0)