diff options
author | Gerhard Weis <g.weis@griffith.edu.au> | 2017-07-05 20:54:03 +1000 |
---|---|---|
committer | Gerhard Weis <g.weis@griffith.edu.au> | 2017-07-05 20:54:03 +1000 |
commit | 0d0abd79a975ed132a8eb43783f87cd84eea9267 (patch) | |
tree | 733231867f0ff1ba3679e1d4564a1b2506353cb2 /src/isodate | |
parent | 1dc3c2481ba32e9dbcad9e55d2c20281f5aa5756 (diff) | |
parent | 6e5802bf7b410551f1dfcaf6ede8638f0f233cad (diff) | |
download | isodate-0d0abd79a975ed132a8eb43783f87cd84eea9267.tar.gz |
Merge branch 'master' of https://github.com/lmazuel/isodate
# Conflicts:
# .travis.yml
# setup.cfg
# src/isodate/tzinfo.py
Diffstat (limited to 'src/isodate')
-rw-r--r-- | src/isodate/isoduration.py | 4 | ||||
-rw-r--r-- | src/isodate/isotime.py | 4 | ||||
-rw-r--r-- | src/isodate/tests/test_pickle.py | 7 |
3 files changed, 13 insertions, 2 deletions
diff --git a/src/isodate/isoduration.py b/src/isodate/isoduration.py index 6da69f5..d64b3c0 100644 --- a/src/isodate/isoduration.py +++ b/src/isodate/isoduration.py @@ -33,6 +33,7 @@ format timedelta or Duration instances as ISO conforming strings. from datetime import timedelta from decimal import Decimal import re +import sys from isodate.duration import Duration from isodate.isoerror import ISO8601Error @@ -51,6 +52,9 @@ ISO8601_PERIOD_REGEX = re.compile( r"(?P<seconds>[0-9]+([,.][0-9]+)?S)?)?$") # regular expression to parse ISO duartion strings. +if sys.version_info[0] >= 3: + basestring = str + def parse_duration(datestring): """ diff --git a/src/isodate/isotime.py b/src/isodate/isotime.py index 9650cda..a430982 100644 --- a/src/isodate/isotime.py +++ b/src/isodate/isotime.py @@ -32,6 +32,7 @@ It supports all basic and extended formats including time zone specifications as described in the ISO standard. ''' import re +import sys from decimal import Decimal from datetime import time @@ -39,6 +40,9 @@ from isodate.isostrf import strftime, TIME_EXT_COMPLETE, TZ_EXT from isodate.isoerror import ISO8601Error from isodate.isotzinfo import TZ_REGEX, build_tzinfo +if sys.version_info > (3,): + long = int + TIME_REGEX_CACHE = [] # used to cache regular expressions to parse ISO time strings. diff --git a/src/isodate/tests/test_pickle.py b/src/isodate/tests/test_pickle.py index 4b824e7..0d8c184 100644 --- a/src/isodate/tests/test_pickle.py +++ b/src/isodate/tests/test_pickle.py @@ -1,5 +1,8 @@ +try: + import cPickle as pickle +except ImportError: + import pickle import unittest -import cPickle as pickle import isodate @@ -31,7 +34,7 @@ class TestPickle(unittest.TestCase): pikl = pickle.dumps(dur, proto) if dur != pickle.loads(pikl): raise Exception("not equal") - except Exception, e: + except Exception as e: failed.append("pickle proto %d failed (%s)" % (proto, repr(e))) self.assertEqual(len(failed), 0, "pickle protos failed: %s" % str(failed)) |