Skip to content

Commit aeb0b98

Browse files
timfelfangerer
authored andcommitted
be unforgiving when a foreign object lies to use about what it can be unwrapped to
1 parent 51a1a24 commit aeb0b98

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/TruffleObjectBuiltins.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static Object[] unpackForeignArray(Object left, InteropLibrary lib, PForeignToPT
151151
return data;
152152
}
153153
} catch (UnsupportedMessageException | InvalidArrayIndexException e) {
154-
// fall through
154+
throw new IllegalStateException("object does not unpack as it claims to");
155155
}
156156
return null;
157157
}
@@ -208,7 +208,7 @@ Object doComparisonBool(Object left, Object right,
208208
try {
209209
return op.executeObject(lib.asBoolean(left), right);
210210
} catch (UnsupportedMessageException e) {
211-
return PNotImplemented.NOT_IMPLEMENTED;
211+
throw new IllegalStateException("object does not unpack as it claims to");
212212
}
213213
}
214214

@@ -218,7 +218,7 @@ Object doComparisonLong(Object left, Object right,
218218
try {
219219
return op.executeObject(lib.asLong(left), right);
220220
} catch (UnsupportedMessageException e) {
221-
return PNotImplemented.NOT_IMPLEMENTED;
221+
throw new IllegalStateException("object does not unpack as it claims to");
222222
}
223223
}
224224

@@ -228,7 +228,7 @@ Object doComparisonDouble(Object left, Object right,
228228
try {
229229
return op.executeObject(lib.asDouble(left), right);
230230
} catch (UnsupportedMessageException e) {
231-
return PNotImplemented.NOT_IMPLEMENTED;
231+
throw new IllegalStateException("object does not unpack as it claims to");
232232
}
233233
}
234234

@@ -277,7 +277,7 @@ Object doComparisonStringR(Object left, Object right,
277277
try {
278278
return op.executeObject(right, lib.asString(left));
279279
} catch (UnsupportedMessageException e) {
280-
return PNotImplemented.NOT_IMPLEMENTED;
280+
throw new IllegalStateException("object does not unpack as it claims to");
281281
}
282282
}
283283

@@ -350,7 +350,7 @@ static Object doForeignArray(Object left, Object right,
350350
try {
351351
rightInt = lib.asInt(right);
352352
} catch (UnsupportedMessageException e) {
353-
return PNotImplemented.NOT_IMPLEMENTED;
353+
throw new IllegalStateException("object does not unpack as it claims to");
354354
}
355355
Object[] unpackForeignArray = unpackForeignArray(left, lib, convert);
356356
if (unpackForeignArray != null) {
@@ -466,7 +466,7 @@ Object doComparisonBool(Object left, Object right,
466466
try {
467467
return comparisonNode.executeBool(lib.asBoolean(left), right);
468468
} catch (UnsupportedMessageException e) {
469-
return PNotImplemented.NOT_IMPLEMENTED;
469+
throw new IllegalStateException("object does not unpack as it claims to");
470470
}
471471
}
472472

@@ -476,7 +476,7 @@ Object doComparisonLong(Object left, Object right,
476476
try {
477477
return comparisonNode.executeWith(lib.asLong(left), right);
478478
} catch (UnsupportedMessageException e) {
479-
return PNotImplemented.NOT_IMPLEMENTED;
479+
throw new IllegalStateException("object does not unpack as it claims to");
480480
}
481481
}
482482

@@ -486,7 +486,7 @@ Object doComparisonDouble(Object left, Object right,
486486
try {
487487
return comparisonNode.executeWith(lib.asDouble(left), right);
488488
} catch (UnsupportedMessageException e) {
489-
return PNotImplemented.NOT_IMPLEMENTED;
489+
throw new IllegalStateException("object does not unpack as it claims to");
490490
}
491491
}
492492

@@ -499,7 +499,7 @@ Object doComparison(@SuppressWarnings("unused") Object left, Object right,
499499
@SuppressWarnings("unused")
500500
@Fallback
501501
public PNotImplemented doGeneric(Object left, Object right) {
502-
return PNotImplemented.NOT_IMPLEMENTED;
502+
throw new IllegalStateException("object does not unpack as it claims to");
503503
}
504504
}
505505

0 commit comments

Comments
 (0)