|
61 | 61 | import java.nio.charset.StandardCharsets;
|
62 | 62 | import java.util.WeakHashMap;
|
63 | 63 |
|
| 64 | +import com.oracle.truffle.api.interop.UnknownIdentifierException; |
64 | 65 | import org.graalvm.collections.Pair;
|
65 | 66 |
|
66 | 67 | import com.oracle.graal.python.PythonLanguage;
|
@@ -1651,13 +1652,20 @@ Object execute(Object[] arguments,
|
1651 | 1652 | Object[] elements = new Object[n];
|
1652 | 1653 | try {
|
1653 | 1654 | for (int i = 0; i < elements.length; i++) {
|
1654 |
| - elements[i] = asPythonObjectNode.execute(nativeContext, lib.readArrayElement(typedArrayPtr, i)); |
| 1655 | + // This will read an element of a 'HPy arr[]' and the returned value will be |
| 1656 | + // an HPy "structure". So, we also need to read element "_i" to get the |
| 1657 | + // internal handle value. |
| 1658 | + Object hpyStructPtr = lib.readArrayElement(typedArrayPtr, i); |
| 1659 | + elements[i] = asPythonObjectNode.execute(nativeContext, lib.readMember(hpyStructPtr, GraalHPyHandle.I)); |
1655 | 1660 | }
|
1656 | 1661 | } catch (UnsupportedMessageException e) {
|
1657 | 1662 | throw CompilerDirectives.shouldNotReachHere(e);
|
1658 | 1663 | } catch (InvalidArrayIndexException e) {
|
1659 | 1664 | CompilerDirectives.transferToInterpreterAndInvalidate();
|
1660 | 1665 | throw raiseNode.raise(SystemError, "Cannot access index %d although array should have size %d ", e.getInvalidIndex(), n);
|
| 1666 | + } catch (UnknownIdentifierException e) { |
| 1667 | + CompilerDirectives.transferToInterpreterAndInvalidate(); |
| 1668 | + throw raiseNode.raise(SystemError, "Cannot read handle value"); |
1661 | 1669 | }
|
1662 | 1670 |
|
1663 | 1671 | return asHandleNode.execute(nativeContext, factory.createTuple(elements));
|
|
0 commit comments