Skip to content

Commit 5e48a9f

Browse files
committed
Report all interop exception's type as ForeignException
1 parent 86d9f88 commit 5e48a9f

File tree

1 file changed

+2
-15
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object

1 file changed

+2
-15
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetClassNode.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
import com.oracle.graal.python.nodes.PNodeWithContext;
6060
import com.oracle.graal.python.nodes.truffle.PythonTypes;
6161
import com.oracle.graal.python.runtime.exception.PException;
62-
import com.oracle.truffle.api.CompilerDirectives;
6362
import com.oracle.truffle.api.dsl.Bind;
6463
import com.oracle.truffle.api.dsl.Cached;
6564
import com.oracle.truffle.api.dsl.Fallback;
@@ -68,9 +67,6 @@
6867
import com.oracle.truffle.api.dsl.Specialization;
6968
import com.oracle.truffle.api.dsl.TypeSystemReference;
7069
import com.oracle.truffle.api.exception.AbstractTruffleException;
71-
import com.oracle.truffle.api.interop.ExceptionType;
72-
import com.oracle.truffle.api.interop.InteropLibrary;
73-
import com.oracle.truffle.api.interop.UnsupportedMessageException;
7470
import com.oracle.truffle.api.library.CachedLibrary;
7571
import com.oracle.truffle.api.object.DynamicObjectLibrary;
7672
import com.oracle.truffle.api.object.Shape;
@@ -197,9 +193,8 @@ static Object getNativeVoidPtr(@SuppressWarnings("unused") PythonNativeVoidPtr o
197193
return PythonBuiltinClassType.PInt;
198194
}
199195

200-
@Specialization(guards = "isForeignRuntimeException(object, lib)")
201-
static Object getTruffleException(@SuppressWarnings("unused") AbstractTruffleException object,
202-
@SuppressWarnings("unused") @CachedLibrary(limit = "3") InteropLibrary lib) {
196+
@Specialization
197+
static Object getTruffleException(@SuppressWarnings("unused") AbstractTruffleException object) {
203198
/*
204199
* Special case: if Python code asks for the class of a foreign exception, we return a
205200
* Python type that inherits from BaseException. We do this because Python users usually
@@ -217,12 +212,4 @@ static Object getForeign(@SuppressWarnings("unused") Object object) {
217212
protected static boolean hasInitialClass(Shape shape) {
218213
return (shape.getFlags() & PythonObject.CLASS_CHANGED_FLAG) == 0;
219214
}
220-
221-
protected static boolean isForeignRuntimeException(AbstractTruffleException e, InteropLibrary lib) {
222-
try {
223-
return lib.isException(e) && lib.getExceptionType(e) == ExceptionType.RUNTIME_ERROR;
224-
} catch (UnsupportedMessageException ex) {
225-
throw CompilerDirectives.shouldNotReachHere(ex);
226-
}
227-
}
228215
}

0 commit comments

Comments
 (0)