Author anakha
Recipients anakha
Date 2008-05-29.18:35:53
SpamBayes Score 0.0366248
Marked as misclassified No
Message-id <1212086155.65.0.0693111742843.issue3004@psf.upfronthosting.co.za>
In-reply-to
Content
When calling the indices method of a slice object with a negative stop
larger in absolute value than the length passed, the returned stop value
is always -1.  It should be 0 when the step is positive.

Current behavior:

>>> slice(-10).indices(11)
(0, 1, 1)
>>> slice(-10).indices(10)
(0, 0, 1)
>>> slice(-10).indices(9)
(0, -1, 1)
>>> slice(-10).indices(8)
(0, -1, 1)

Expected behavior:

>>> slice(-10).indices(11)
(0, 1, 1)
>>> slice(-10).indices(10)
(0, 0, 1)
>>> slice(-10).indices(9)
(0, 0, 1)
>>> slice(-10).indices(8)
(0, 0, 1)

The patch I submit trivially fixes this while preserving the expected -1
when the step is negative like in:

>>> slice(None, -10, -1).indices(8)
(7, -1, -1)

This issue affects python 2.5 and 2.6 at least.  I did not test with
other versions.
History
Date User Action Args
2008-05-29 18:35:56anakhasetspambayes_score: 0.0366248 -> 0.0366248
recipients: + anakha
2008-05-29 18:35:55anakhasetspambayes_score: 0.0366248 -> 0.0366248
messageid: <1212086155.65.0.0693111742843.issue3004@psf.upfronthosting.co.za>
2008-05-29 18:35:54anakhalinkissue3004 messages
2008-05-29 18:35:53anakhacreate