Skip to content

Commit 59ba159

Browse files
authored
compat: catch dateutil ParserError (#45438)
1 parent 399962c commit 59ba159

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/core/dtypes/cast.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121
import warnings
2222

23+
from dateutil.parser import ParserError
2324
import numpy as np
2425

2526
from pandas._libs import lib
@@ -1336,9 +1337,8 @@ def maybe_cast_to_datetime(
13361337
value = dta.tz_localize("UTC").tz_convert(dtype.tz)
13371338
except OutOfBoundsDatetime:
13381339
raise
1339-
except ValueError:
1340-
# TODO(GH#40048): only catch dateutil's ParserError
1341-
# once we can reliably import it in all supported versions
1340+
except ParserError:
1341+
# Note: this is dateutil's ParserError, not ours.
13421342
pass
13431343

13441344
elif getattr(vdtype, "kind", None) in ["m", "M"]:

0 commit comments

Comments
 (0)