summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Mazuel <lmazuel@microsoft.com>2017-06-29 01:14:09 (GMT)
committerGitHub <noreply@github.com>2017-06-29 01:14:09 (GMT)
commit3aaf2547850c5e015c88e475364ac77f7fd6a92f (patch)
treedb99ccf3b162039b4c1264b71c57db8d010c52e1
parent5ac960d6f4503dfbeb6493b5dfb0c64fc486a70c (diff)
downloadisodate-3aaf2547850c5e015c88e475364ac77f7fd6a92f.tar.gz
Py3 compat
-rw-r--r--src/isodate/isoduration.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/isodate/isoduration.py b/src/isodate/isoduration.py
index c3cfc65..ab13acb 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,8 @@ 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):
"""
@@ -80,7 +83,7 @@ def parse_duration(datestring):
The alternative format does not support durations with years, months or
days set to 0.
"""
- if not isinstance(datestring, (str, unicode)):
+ if not isinstance(datestring, basestring):
raise TypeError("Expecting a string %r" % datestring)
match = ISO8601_PERIOD_REGEX.match(datestring)
if not match: