Skip to content

Commit 9e7c083

Browse files
committed
support longs as slice start
1 parent 6c4b9fb commit 9e7c083

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/subscript/SliceLiteralNode.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ public PSlice doSlice(int start, @SuppressWarnings("unused") PNone stop, @Suppre
7878
return factory().createSlice(start, MISSING_INDEX, MISSING_INDEX);
7979
}
8080

81+
@TruffleBoundary
82+
@Specialization
83+
public PSlice doPSlice(long start, @SuppressWarnings("unused") PNone stop, @SuppressWarnings("unused") PNone step) {
84+
try {
85+
return factory().createSlice(Math.toIntExact(start), MISSING_INDEX, 1);
86+
} catch (ArithmeticException e) {
87+
throw raise(IndexError, "cannot fit 'int' into an index-sized integer");
88+
}
89+
}
90+
8191
@Specialization
8292
public PSlice doSlice(int start, @SuppressWarnings("unused") PNone stop, int step) {
8393
return factory().createSlice(start, MISSING_INDEX, step);

0 commit comments

Comments
 (0)