Skip to content

Commit dfc7033

Browse files
committed
Fixes #45506 Catch overflow error when converting to datetime
Exception is raised when year is greater than 32 bit signed integer TODO: Remove this when its fixed in Python
1 parent 44cde19 commit dfc7033

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/core/arrays/datetimes.py

+4
Original file line numberDiff line numberDiff line change
@@ -2215,6 +2215,10 @@ def objects_to_datetime64ns(
22152215
return values.view("i8"), tz_parsed
22162216
except (ValueError, TypeError):
22172217
raise err
2218+
except OverflowError as err:
2219+
# Exception is raised when year is greater than 32 bit signed integer
2220+
# TODO: Remove this when its fixed in Python
2221+
raise ValueError("Value out of range. This is Python's datetime's limitation.") from err
22182222

22192223
if tz_parsed is not None:
22202224
# We can take a shortcut since the datetime64 numpy array

0 commit comments

Comments
 (0)