summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-11-15 16:38:27 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-11-15 16:38:27 +0100
commit2fb3a0e13e2379f997d48ce3121acd94fcf7fa5d (patch)
tree112b1503ef07b22604523313cd37e92d7f595b5e
parent2e3a3ace848d25c8c7cbee4d7da671a10375abbb (diff)
Compatibility with dateutil < 2.8
-rw-r--r--lesana/types.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lesana/types.py b/lesana/types.py
index ce15b69..1d5322e 100644
--- a/lesana/types.py
+++ b/lesana/types.py
@@ -202,9 +202,11 @@ class LesanaDatetime(LesanaType):
return data
if isinstance(data, datetime.date):
return datetime.datetime(data.year, data.month, data.day)
+ # compatibility with dateutil before 2.8
+ ParserError = getattr(dateutil.parser, 'ParserError', ValueError)
try:
return dateutil.parser.parse(data)
- except dateutil.parser.ParserError:
+ except ParserError:
raise LesanaValueError(
"Invalid value for datetime field: {}".format(data)
)