In CircuitPython (only), a the slice assignment to [-1👎-3] of an
ndarray of length 1 caused a crash. This appears to be because in
CircuitPython, the internal pointer of an empty array was NULL rather than
pointing at some memory which happened to be valid and assignable.
This appears to be a corner case of how integer promotion rules work in C.
The expression `slice.stop - slice.start + (slice.step + correction)`
is type `unsigned long` and on a LP64 platform its value is
18446744073709551614. This led to the function returning that this slice
had length 1 instead, during the automated tests.
By casting to signed types capable of holding indices and sizes, the
problem is corrected on both platforms.
I don't know why, but mp_seq_get_fast_slice_indexes adjusts "stop" in a
surprising way, and that led to the (remaining) differences in slicing
between ulab and built-in lists.
// If the index is negative then stop points to the last item, not after it
if (indexes->step < 0) {
indexes->stop++;
}
Call the underlying routine, mp_obj_slice_indices, instead.
- Adapt to signature of mp_make_new_fun_t for mpy and cpy by ifdef
- Use MP_OBJ_IS_TYPE instead of mp_obj_is_type
- Ditto MP_OBJ_IS_INT
- Use mp_const_none instead of MP_ROM_NONE
- Ditto mp_const_true, mp_const_false