From 71cda461c5cddb43d6c77681204aa52f51e41b1a Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Tue, 7 Jan 2014 17:19:16 -0500 Subject: [PATCH] BUG: Fix check for cached public data for Python 2.7 Python 2 and 3 throw different exception types when a file does not exist. Catch both exception types to trigger the download, so that the loader works under both Python versions. --- zipline/data/loader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zipline/data/loader.py b/zipline/data/loader.py index 08d724d9..b00d8e91 100644 --- a/zipline/data/loader.py +++ b/zipline/data/loader.py @@ -158,7 +158,7 @@ def load_market_data(bm_symbol='^GSPC'): bm_filepath = get_data_filepath(get_benchmark_filename(bm_symbol)) try: saved_benchmarks = pd.Series.from_csv(bm_filepath) - except OSError: + except (OSError, IOError): print(""" data files aren't distributed with source. Fetching data from Yahoo Finance. @@ -205,7 +205,7 @@ Fetching data from Yahoo Finance. tr_filepath = get_data_filepath(filename) try: saved_curves = pd.DataFrame.from_csv(tr_filepath) - except OSError: + except (OSError, IOError): print(""" data files aren't distributed with source. Fetching data from {0}