Issue 1456470: sliceobject ssize_t (and index) not completed (original) (raw)

sliceobject and ceval changed the parameter types of slice objects to ssize_t, but the code still requires an int (sometimes not even a long); it should use the new index slot; at the very least, it should be consistent about what it does accept.

In http://svn.python.org/view/python/trunk/Objects/ sliceobject.c?rev=42382&view=markup

[issue 1] function PySlice_GetIndices takes Py_ssize_t parameters for (length, start, stop, step)

but then does a PyInt_Check on each of start, stop, step. (An XXX to allow longs was also removed.) It * should* use the new index slot.

[issue 2] Later in the same file, function slice_ indices takes a PyObject len parameter, but then uses PyInt_AsLong rather than index (or even PyInt_ AsSsize_t) to create Py_ssize_t ilen.

[issue 3]

http://svn.python.org/view/python/trunk/Python/ceval.c? rev=42382&view=markup

function _PyEval_SliceIndex accepts only ints and longs, and longs will be converted to ints with clipping.

It should allow anything with index, and clip only to ssize_t rather than int.

[issue 4] ISINT still insists on int or long -- I thought I saw a fix for this already in the index patches.

[issue 5] apply_slice and assign_slice changed the types of ilow and ihigh, but still initializes them to INT_MAX rather than ssize_t max.