From d27a1103fac41fd3eb4231a89fc35044641b317a Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Wed, 12 Mar 2014 17:19:49 +0000 Subject: [PATCH] workaround a dateutil bug In the latest released version of dateutil, there's a bug whereby a TypeError can be raised whilst parsing a date. This is because it calls a method which it expects to return 2 arguments, however it can return 1 depending upon the input, which results in a TypeError: ArgType not iterable exception. Since this is equivalent to a failed parse anyway, we can treat it the same as a ValueError. --- mongoengine/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine/fields.py b/mongoengine/fields.py index 82642cda..85a1a743 100644 --- a/mongoengine/fields.py +++ b/mongoengine/fields.py @@ -391,7 +391,7 @@ class DateTimeField(BaseField): if dateutil: try: return dateutil.parser.parse(value) - except ValueError: + except (TypeError, ValueError): return None # split usecs, because they are not recognized by strptime.