Message 174678 - Python tracker (original) (raw)
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