Issue 3301: Bisect functions behaved badly when lo was negative.

This commit is contained in:
Raymond Hettinger 2008-07-10 14:03:19 +00:00
parent d2cd86ddd5
commit 3cd1e42dca
4 changed files with 27 additions and 0 deletions

View file

@ -9,6 +9,8 @@ def insort_right(a, x, lo=0, hi=None):
slice of a to be searched.
"""
if lo < 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(a)
while lo < hi:
@ -30,6 +32,8 @@ def bisect_right(a, x, lo=0, hi=None):
slice of a to be searched.
"""
if lo < 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(a)
while lo < hi:
@ -49,6 +53,8 @@ def insort_left(a, x, lo=0, hi=None):
slice of a to be searched.
"""
if lo < 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(a)
while lo < hi:
@ -69,6 +75,8 @@ def bisect_left(a, x, lo=0, hi=None):
slice of a to be searched.
"""
if lo < 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(a)
while lo < hi: