Skip to content

Commit f0df15c

Browse files
timfelfangerer
authored andcommitted
if readArrayElement fails on a mapping, assume this message is unsupported
1 parent 9532804 commit f0df15c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ public boolean hasArrayElements(
211211
@ExportMessage
212212
public Object readArrayElement(long key,
213213
@Shared("isSequenceNode") @Cached IsSequenceNode isSequenceNode,
214+
@Shared("isMapping") @Cached IsMappingNode isMapping,
214215
@Shared("isIterableNode") @Cached IsIterableNode isIterableNode,
215216
@Shared("getItemNode") @Cached PInteropSubscriptNode getItemNode,
216217
@Exclusive @Cached LookupInheritedAttributeNode.Dynamic lookupIterNode,
@@ -222,9 +223,13 @@ public Object readArrayElement(long key,
222223
try {
223224
return toForeign.executeConvert(getItemNode.execute(this, key));
224225
} catch (PException e) {
225-
// TODO(fa) refine exception handling
226-
// it's a sequence, so we assume the index is wrong
227-
throw InvalidArrayIndexException.create(key);
226+
if (isMapping.execute(this)) {
227+
throw UnsupportedMessageException.create();
228+
} else {
229+
// TODO(fa) refine exception handling
230+
// it's a sequence, so we assume the index is wrong
231+
throw InvalidArrayIndexException.create(key);
232+
}
228233
}
229234
}
230235

0 commit comments

Comments
 (0)