New submission from Arnaud Bergeron <[EMAIL PROTECTED]>: 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. ---------- components: Interpreter Core files: slice.patch keywords: patch messages: 67506 nosy: anakha severity: normal status: open title: Bug in slice.indices() type: behavior versions: Python 2.5, Python 2.6 Added file: http://bugs.python.org/file10466/slice.patch _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3004> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com