From eb6b6d046d23a7635e0dc215b9ded33ed3e6569c Mon Sep 17 00:00:00 2001 From: "phil.zhang" Date: Tue, 5 Jul 2016 16:58:46 +0800 Subject: [PATCH] BUG: Change str to string_types to avoid errors When in python2.7, and unicode_literals is imported type check will raise error because 'type' is not str but unicode --- zipline/_protocol.pyx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zipline/_protocol.pyx b/zipline/_protocol.pyx index a1b68a05..626be3ce 100644 --- a/zipline/_protocol.pyx +++ b/zipline/_protocol.pyx @@ -20,7 +20,7 @@ from pandas.tslib import normalize_date import pandas as pd import numpy as np -from six import iteritems, PY2 +from six import iteritems, PY2, string_types from cpython cimport bool from collections import Iterable @@ -29,7 +29,7 @@ from zipline.zipline_warnings import ZiplineDeprecationWarning cdef bool _is_iterable(obj): - return isinstance(obj, Iterable) and not isinstance(obj, str) + return isinstance(obj, Iterable) and not isinstance(obj, string_types) # Wraps doesn't work for method objects in python2. Docs should be generated @@ -247,7 +247,7 @@ cdef class BarData: return dt - @check_parameters(('assets', 'fields'), ((Asset, str), str)) + @check_parameters(('assets', 'fields'), ((Asset, string_types), string_types)) def current(self, assets, fields): """ Returns the current value of the given assets for the given fields @@ -569,7 +569,7 @@ cdef class BarData: return not (last_traded_dt is pd.NaT) @check_parameters(('assets', 'fields', 'bar_count', 'frequency'), - ((Asset, str), str, int, str)) + ((Asset, string_types), string_types, int, string_types)) def history(self, assets, fields, bar_count, frequency): """ Returns a window of data for the given assets and fields. @@ -615,7 +615,7 @@ cdef class BarData: If the current simulation time is not a valid market time, we use the last market close instead. """ - if isinstance(fields, str): + if isinstance(fields, string_types): single_asset = isinstance(assets, Asset) if single_asset: