# HG changeset patch # User Paul Boddie # Date 1374531478 -7200 # Node ID e472e3641070431eb5f39d73b210e5ed20d85c8b # Parent 88b96032ae75536b357d592649cac4f0a16ea072 Introduced an explicit error condition where pytz is not installed and an attempt is made to inspect Olson time zone information. diff -r 88b96032ae75 -r e472e3641070 DateSupport.py --- a/DateSupport.py Tue Jul 16 17:10:54 2013 +0200 +++ b/DateSupport.py Tue Jul 23 00:17:58 2013 +0200 @@ -632,7 +632,7 @@ """ olson = self.olson_identifier() - if olson and pytz: + if olson: tz = pytz.timezone(olson) data = self.padded().as_tuple()[:6] dt = datetime.datetime(*data) @@ -665,6 +665,8 @@ period of ambiguity. """ + self._check_pytz() + try: return self._as_olson_datetime() except (pytz.UnknownTimeZoneError, pytz.AmbiguousTimeError): @@ -679,6 +681,8 @@ "Return whether the time is local and ambiguous." + self._check_pytz() + try: self._as_olson_datetime() except (pytz.UnknownTimeZoneError, pytz.AmbiguousTimeError): @@ -686,6 +690,11 @@ return 0 + def _check_pytz(self): + if not pytz: + raise NotImplementedError, "pytz must be installed for Olson " \ + "time zones to be supported" + class Timespan(ActsAsTimespan, Convertible): """ diff -r 88b96032ae75 -r e472e3641070 README.txt --- a/README.txt Tue Jul 16 17:10:54 2013 +0200 +++ b/README.txt Tue Jul 23 00:17:58 2013 +0200 @@ -64,6 +64,12 @@ If time zone handling is not required, pytz need not be installed. It is, however, highly recommended that pytz be installed. +New in MoinSupport 0.4.1 (Changes since MoinSupport 0.4) +-------------------------------------------------------- + + * Introduced an explicit error condition where pytz is not installed and an + attempt is made to inspect Olson time zone information. + New in MoinSupport 0.4 (Changes since MoinSupport 0.3) ------------------------------------------------------