[issue3004] Bug in slice.indices()

Arnaud Bergeron report at bugs.python.org
Fri Jun 6 00:21:12 CEST 2008


Arnaud Bergeron <abergeron at gmail.com> added the comment:

It's for code that I am developping.  I developped a class to allow
full slicing over iterators (like what islice does, but with negative
indexes).  When I have a positive step I just foward the call to
isclice using slice.indices() to compute my limits.  But with this
behavior, I am forced to wrap the indices() call with a function that
patches this case.

I agree that for the common usage of computing the limits of a for
loop it doesn't matter.  But it is really surprising when you realise
this behavior is what is causing these exceptions after having passed
half a day trying to debug your code.

In fact, I think this bug should really be more of a documentation bug
and I should propose a patch to add clearer documentation to this
method.  But the fix proposed should also go in because:
- it's trivial
- it's better

Documentation for the method will be submitted later tomorrow.  Should
I post another report or just attach it to this one?

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3004>
_______________________________________


More information about the Python-bugs-list mailing list