From bd7f3ad1008ee65375fe657c5aee3dbf04a8e0a0 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Mon, 30 Jan 2017 22:13:18 -0500 Subject: [PATCH] MAINT: Raise LookupError instead of KeyError. KeyError calls __repr__ on its input, which makes it really unpleasant to read multi-line strings. --- zipline/utils/pandas_utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/zipline/utils/pandas_utils.py b/zipline/utils/pandas_utils.py index 141b46b0..ccac273a 100644 --- a/zipline/utils/pandas_utils.py +++ b/zipline/utils/pandas_utils.py @@ -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