Issue222800

classification
Title: __getslice__ bug
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: bckfnn
Priority: low Keywords:

Created on 2000-11-18.18:54:51 by bckfnn, last changed 2000-12-12.09:00:40 by bckfnn.

Messages
msg37 (view) Author: Finn Bock (bckfnn) Date: 2000-11-18.18:54:51
__getitem__ has a bug at boundaries.

Example:
>>> "012345"[-100:-100:-1]
'0' # should be ''

The problem appears to be in getStop and(?) getStart in PySequence. These
functions 
should return values in [0,length] for positive steps and [-1,length-1] for
negative
steps. Currently, getStart always returns values in [0,length] and getStop 
returns values between [0, length] and [-1, length] for positive and negative
values of step respectively. I believe the above problem is due to getStart, and
I 
haven't found a problem related to getStop, but it probably wouldn't hurt to
fix
it too...
msg38 (view) Author: Finn Bock (bckfnn) Date: 2000-12-12.09:00:40
I'm not sure what this example should return. When looking at NumPy, I get

Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
>>> from Numeric import array
>>> a = array([0, 1,2,3,4,5,6,7,8])
>>> print a[::-1]
[8 7 6 5 4 3 2 1 0]
>>> print a[-100:-100:-1]
[0]

It seems like a huge negative start value is interpreted as starting at 0. Based on this, I'm going to close this bug. 
History
Date User Action Args
2000-11-18 18:54:51bckfnncreate