Skip to content

Commit 8ebd1b6

Browse files
author
Sumanau Sareen
committed
Add error message for tz_localize
1 parent 428791c commit 8ebd1b6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/_libs/tslibs/conversion.pyx

+6-2
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,14 @@ cdef inline check_overflows(_TSObject obj):
523523
# GH#12677
524524
if obj.dts.year == 1677:
525525
if not (obj.value < 0):
526-
raise OutOfBoundsDatetime
526+
raise OutOfBoundsDatetime(
527+
f'Timestamp cannot be converted within implementation bounds'
528+
)
527529
elif obj.dts.year == 2262:
528530
if not (obj.value > 0):
529-
raise OutOfBoundsDatetime
531+
raise OutOfBoundsDatetime(
532+
f'Timestamp cannot be converted within implementation bounds'
533+
)
530534

531535

532536
# ----------------------------------------------------------------------

pandas/tests/scalar/timestamp/test_timezones.py

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_tz_localize_pushes_out_of_bounds(self):
2525
# GH#12677
2626
# tz_localize that pushes away from the boundary is OK
2727
pac = Timestamp.min.tz_localize("US/Pacific")
28+
msg = "Timestamp cannot be converted within implementation bounds"
2829
assert pac.value > Timestamp.min.value
2930
pac.tz_convert("Asia/Tokyo") # tz_convert doesn't change value
3031
with pytest.raises(OutOfBoundsDatetime, match=msg):

0 commit comments

Comments
 (0)