From dee832a61d2a5498581e7bae99e141bacf3fe4da Mon Sep 17 00:00:00 2001 From: Brock Date: Mon, 17 Jan 2022 19:15:55 -0800 Subject: [PATCH] compat: catch dateutil ParserError --- pandas/core/dtypes/cast.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index 9d7e07df871d1..141a609e86809 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -20,6 +20,7 @@ ) import warnings +from dateutil.parser import ParserError import numpy as np from pandas._libs import lib @@ -1336,9 +1337,8 @@ def maybe_cast_to_datetime( value = dta.tz_localize("UTC").tz_convert(dtype.tz) except OutOfBoundsDatetime: raise - except ValueError: - # TODO(GH#40048): only catch dateutil's ParserError - # once we can reliably import it in all supported versions + except ParserError: + # Note: this is dateutil's ParserError, not ours. pass elif getattr(vdtype, "kind", None) in ["m", "M"]: