aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-12-07 17:27:49 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-12-07 17:27:49 +0100
commit567e9ec698d3807a6e779432adea297c98c08cd4 (patch)
tree826d8573b2802cad9648c9ae3e69c6fd496e676b
parent80baf34219dc692b2471add8a1ebc2960d5e2f59 (diff)
compatibility fix with dateutil before 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 1d5322e..0b278d6 100644
--- a/lesana/types.py
+++ b/lesana/types.py
@@ -226,9 +226,11 @@ class LesanaDate(LesanaType):
return data
if isinstance(data, datetime.date):
return data
+ # 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 date field: {}".format(data)
)