From 2fb3a0e13e2379f997d48ce3121acd94fcf7fa5d Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sun, 15 Nov 2020 16:38:27 +0100 Subject: Compatibility with dateutil < 2.8 --- lesana/types.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) ) -- cgit v1.2.3