[issue21856] memoryview: test slick clamping

2014-06-28 Thread Stefan Krah

Stefan Krah added the comment:

Since the rewrite in 3.3 many memoryview tests are actually in test_buffer.py.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21856
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21856] memoryview: test slick clamping

2014-06-28 Thread Stefan Krah

Stefan Krah added the comment:

And Terry is right, the actual slice clamping happens in
PySlice_GetIndicesEx(), which should always produce values
that are in the correct range.  Hence the tests focus on
slices that already are in the correct range.

I'm not sure if PySlice_GetIndicesEx() itself has tests somewhere.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21856
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21856] memoryview: test slick clamping

2014-06-27 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Memoryview should definitely have the same slice tests as other sequence 
objects. Go ahead and check.

I believe slice clamping itself should now be done by slice.indices, not by 
each class.

S.indices(len) - (start, stop, stride)

Assuming a sequence of length len, calculate the start and stop
indices, and the stride length of the extended slice described by
S. Out of bounds indices are clipped in a manner consistent with the
handling of normal slices.

It seems like this was written before it was normal for every slice to have a 
step (stride), defaulting to None/1. It definitely comes from 2.x, before 
__getslice__ was folded into __getitem__

I expect builtin 3.x sequence objects should all use something like the C 
equivalent of
def __getitem__(self, ob):
if type(ob) is slice:
   start, stop, stride = ob.indices(self.len)
   ...

--
title: memoryview: no overflow on large slice values (start, stop, step) - 
memoryview: test slick clamping

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21856
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com