Be more explicit about range policing

(rather than doing it in some roundabout crazy way)
This commit is contained in:
Peter Eckersley 2016-06-24 18:56:30 -07:00
parent 880cb03191
commit 0dc4639cbf

View file

@ -239,6 +239,8 @@ class UnspacedList(list):
# Normalize indexes like list[-1] etc, and save the result
if idx < 0:
idx = len(self) + idx
if not 0 <= idx < len(self):
raise IndexError("list index out of range")
idx0 = idx
# Count the number of spaces in the spaced list before idx in the unspaced one
while idx != -1: