Skip to content

Commit 0e95fc6

Browse files
committed
Add missing specializations to 'PyTruffleSlice_GetIndicesEx'.
1 parent 0ccaf70 commit 0e95fc6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TruffleCextBuiltins.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,24 @@ Object doUnpack(int start, int stop, int step, long length) {
12721272
SliceInfo actualIndices = tmpSlice.computeActualIndices((int) length);
12731273
return factory().createTuple(new Object[]{actualIndices.start, actualIndices.stop, actualIndices.step, actualIndices.length});
12741274
}
1275+
1276+
@Specialization(rewriteOn = ArithmeticException.class)
1277+
Object doUnpackLong(long start, long stop, long step, long length) {
1278+
PSlice tmpSlice = factory().createSlice(PInt.intValueExact(start), PInt.intValueExact(stop), PInt.intValueExact(step));
1279+
SliceInfo actualIndices = tmpSlice.computeActualIndices((int) length);
1280+
return factory().createTuple(new Object[]{actualIndices.start, actualIndices.stop, actualIndices.step, actualIndices.length});
1281+
}
1282+
1283+
@Specialization(replaces = "doUnpackLong")
1284+
Object doUnpackLongOvf(long start, long stop, long step, long length) {
1285+
try {
1286+
PSlice tmpSlice = factory().createSlice(PInt.intValueExact(start), PInt.intValueExact(stop), PInt.intValueExact(step));
1287+
SliceInfo actualIndices = tmpSlice.computeActualIndices((int) length);
1288+
return factory().createTuple(new Object[]{actualIndices.start, actualIndices.stop, actualIndices.step, actualIndices.length});
1289+
} catch (ArithmeticException e) {
1290+
throw raiseIndexError();
1291+
}
1292+
}
12751293
}
12761294

12771295
@Builtin(name = "PyTruffle_Add_Subclass", fixedNumOfArguments = 3)

0 commit comments

Comments
 (0)