From b48a7bd6b6ea8c29879c586d65588933dc8ffbef Mon Sep 17 00:00:00 2001 From: "Stephen J. Fuhry" Date: Sat, 24 Sep 2016 14:58:22 -0400 Subject: [PATCH] use BaseTzInfo since pytz also uses StaticTzInfo --- sqlalchemy_utils/types/timezone.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sqlalchemy_utils/types/timezone.py b/sqlalchemy_utils/types/timezone.py index 239712c..b474066 100644 --- a/sqlalchemy_utils/types/timezone.py +++ b/sqlalchemy_utils/types/timezone.py @@ -52,9 +52,10 @@ class TimezoneType(types.TypeDecorator, ScalarCoercible): elif backend == 'pytz': try: - from pytz import tzfile, timezone + from pytz import timezone + from pytz.tzinfo import BaseTzInfo - self.python_type = tzfile.DstTzInfo + self.python_type = BaseTzInfo self._to = timezone self._from = six.text_type @@ -71,13 +72,11 @@ class TimezoneType(types.TypeDecorator, ScalarCoercible): ) def _coerce(self, value): - if value and not isinstance(value, self.python_type): + if value is not None and not isinstance(value, self.python_type): obj = self._to(value) if obj is None: raise ValueError("unknown time zone '%s'" % value) - return obj - return value def process_bind_param(self, value, dialect):