Skip to content

Commit 4f0b7a2

Browse files
committed
Allow long in PyList_Insert
1 parent e1cf78f commit 4f0b7a2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545
import static com.oracle.graal.python.nodes.ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P;
4646
import static com.oracle.graal.python.nodes.ErrorMessages.LIST_INDEX_OUT_OF_RANGE;
4747
import static com.oracle.graal.python.nodes.ErrorMessages.NATIVE_S_SUBTYPES_NOT_IMPLEMENTED;
48+
4849
import java.util.Arrays;
4950
import java.util.List;
51+
5052
import com.oracle.graal.python.builtins.Builtin;
5153
import com.oracle.graal.python.builtins.CoreFunctions;
5254
import com.oracle.graal.python.builtins.Python3Core;
@@ -85,6 +87,7 @@
8587
import com.oracle.graal.python.runtime.exception.PException;
8688
import com.oracle.graal.python.util.PythonUtils;
8789
import com.oracle.truffle.api.dsl.Cached;
90+
import com.oracle.truffle.api.dsl.Fallback;
8891
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
8992
import com.oracle.truffle.api.dsl.ImportStatic;
9093
import com.oracle.truffle.api.dsl.NodeFactory;
@@ -514,7 +517,7 @@ protected boolean isListSubtype(VirtualFrame frame, Object obj, GetClassNode get
514517
abstract static class PyListInsertNode extends PythonTernaryBuiltinNode {
515518

516519
@Specialization
517-
Object append(VirtualFrame frame, PList list, int i, Object item,
520+
Object insert(VirtualFrame frame, PList list, Object i, Object item,
518521
@Cached ListInsertNode insertNode,
519522
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
520523
try {
@@ -526,18 +529,17 @@ Object append(VirtualFrame frame, PList list, int i, Object item,
526529
}
527530
}
528531

529-
@Specialization(guards = {"!isList(obj)", "isListSubtype(frame, obj, getClassNode, isSubtypeNode)"})
530-
public Object asTupleNative(VirtualFrame frame, @SuppressWarnings("unused") Object obj, @SuppressWarnings("unused") int i, @SuppressWarnings("unused") Object item,
532+
@Specialization(guards = {"!isList(obj)", "isListSubtype(frame, obj, getClassNode, isSubtypeNode)"}, limit = "1")
533+
public Object insertNative(VirtualFrame frame, @SuppressWarnings("unused") Object obj, @SuppressWarnings("unused") long i, @SuppressWarnings("unused") Object item,
531534
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
532535
@SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode,
533536
@Cached PRaiseNativeNode raiseNativeNode) {
534537
return raiseNativeNode.raiseInt(frame, -1, PythonBuiltinClassType.NotImplementedError, NATIVE_S_SUBTYPES_NOT_IMPLEMENTED, "list");
535538
}
536539

537-
@Specialization(guards = {"!isList(obj)", "!isListSubtype(frame, obj, getClassNode, isSubtypeNode)"})
538-
public Object asTuple(VirtualFrame frame, Object obj, @SuppressWarnings("unused") int i, @SuppressWarnings("unused") Object item,
539-
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
540-
@SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode,
540+
@Fallback
541+
@SuppressWarnings("unused")
542+
public Object error(VirtualFrame frame, Object obj, Object i, Object item,
541543
@Cached StrNode strNode,
542544
@Cached PRaiseNativeNode raiseNativeNode) {
543545
return raiseNativeNode.raiseInt(frame, -1, SystemError, BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P, strNode.executeWith(frame, obj), obj);

0 commit comments

Comments
 (0)