MAINT: Raise LookupError instead of KeyError.

KeyError calls __repr__ on its input, which makes it really unpleasant
to read multi-line strings.
This commit is contained in:
Scott Sanderson
2017-01-30 22:13:18 -05:00
parent c092e4db4d
commit bd7f3ad100
+1 -3
View File
@@ -118,9 +118,7 @@ def find_in_sorted_index(dts, dt):
"""
ix = dts.searchsorted(dt)
if dts[ix] != dt:
raise KeyError(
"{0} is not in calendar [{1} ... {2}]".format(dt, dts[0], dts[-1])
)
raise LookupError("{dt} is not in {dts}".format(dt=dt, dts=dts))
return ix