[issue14794] slice.indices raises OverflowError

Mark Dickinson report at bugs.python.org
Sat Nov 3 20:28:20 CET 2012


Mark Dickinson added the comment:

I should note that this patch fixes/changes one other aspect of slice.indices:  namely that it used to accept a negative length, and return essentially meaningless results in that case:

    >>> slice(0, 10, 1).indices(-3)
    (-3, -3, 1)

With the patch, it now raises ValueError if given a negative length:

    >>> slice(0, 10, 1).indices(-3)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: length should not be negative

----------

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


More information about the Python-bugs-list mailing list