@@ -1264,27 +1264,28 @@ Object get() {
1264
1264
}
1265
1265
1266
1266
@ Builtin (name = "PyTruffleSlice_GetIndicesEx" , fixedNumOfArguments = 4 )
1267
+ @ TypeSystemReference (PythonArithmeticTypes .class )
1267
1268
@ GenerateNodeFactory
1268
1269
abstract static class PyTruffleSlice_GetIndicesEx extends NativeBuiltin {
1269
1270
@ Specialization
1270
- Object doUnpack (int start , int stop , int step , long length ) {
1271
+ Object doUnpack (int start , int stop , int step , int length ) {
1271
1272
PSlice tmpSlice = factory ().createSlice (start , stop , step );
1272
- SliceInfo actualIndices = tmpSlice .computeActualIndices (( int ) length );
1273
+ SliceInfo actualIndices = tmpSlice .computeActualIndices (length );
1273
1274
return factory ().createTuple (new Object []{actualIndices .start , actualIndices .stop , actualIndices .step , actualIndices .length });
1274
1275
}
1275
1276
1276
1277
@ Specialization (rewriteOn = ArithmeticException .class )
1277
1278
Object doUnpackLong (long start , long stop , long step , long length ) {
1278
1279
PSlice tmpSlice = factory ().createSlice (PInt .intValueExact (start ), PInt .intValueExact (stop ), PInt .intValueExact (step ));
1279
- SliceInfo actualIndices = tmpSlice .computeActualIndices (( int ) length );
1280
+ SliceInfo actualIndices = tmpSlice .computeActualIndices (PInt . intValueExact ( length ) );
1280
1281
return factory ().createTuple (new Object []{actualIndices .start , actualIndices .stop , actualIndices .step , actualIndices .length });
1281
1282
}
1282
1283
1283
- @ Specialization (replaces = "doUnpackLong" )
1284
+ @ Specialization (replaces = { "doUnpackLong" , "doUnpack" } )
1284
1285
Object doUnpackLongOvf (long start , long stop , long step , long length ) {
1285
1286
try {
1286
1287
PSlice tmpSlice = factory ().createSlice (PInt .intValueExact (start ), PInt .intValueExact (stop ), PInt .intValueExact (step ));
1287
- SliceInfo actualIndices = tmpSlice .computeActualIndices (( int ) length );
1288
+ SliceInfo actualIndices = tmpSlice .computeActualIndices (length > Integer . MAX_VALUE ? Integer . MAX_VALUE : PInt . intValueExact ( length ) );
1288
1289
return factory ().createTuple (new Object []{actualIndices .start , actualIndices .stop , actualIndices .step , actualIndices .length });
1289
1290
} catch (ArithmeticException e ) {
1290
1291
throw raiseIndexError ();
0 commit comments