Skip to content

Commit 03869c5

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 03869c5

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("year out of range") 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)