Skip to content

Commit 10f875c

Browse files
author
Sumanau Sareen
committed
Add error message for tz_localize
1 parent df49f53 commit 10f875c

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

fix_virtualenv

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
ENV_PATH="$(dirname "$(dirname "$(which pip)")")"
4+
SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)"
5+
6+
BAD_ENV_PATHS="/usr/local"
7+
8+
echo "Ensure the root of the broken virtualenv:"
9+
echo " $ENV_PATH"
10+
11+
if [[ -z "$ENV_PATH" ]] || [[ "$ENV_PATH" = *"$BAD_ENV_PATHS"* ]]; then
12+
echo "The root path above doesn't seems to be a valid one."
13+
echo "Please make sure you ACTIVATED the broken virtualenv."
14+
echo "‼️ Exiting for your safety... (thanks @laymonk for reporting this)"
15+
exit 1
16+
fi
17+
18+
read -p "‼️ Press Enter if you are not sure (y/N) " -n 1 -r
19+
echo
20+
if [[ $REPLY =~ ^[Yy]$ ]]; then
21+
echo "♻️ Removing old symbolic links......"
22+
find "$ENV_PATH" -type l -delete -print
23+
echo "💫 Creating new symbolic links......"
24+
$SYSTEM_VIRTUALENV "$ENV_PATH"
25+
echo "🎉 Done!"
26+
fi

pandas/_libs/tslibs/conversion.pyx

+6-2
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,14 @@ cdef inline check_overflows(_TSObject obj):
502502
# GH#12677
503503
if obj.dts.year == 1677:
504504
if not (obj.value < 0):
505-
raise OutOfBoundsDatetime
505+
raise OutOfBoundsDatetime(
506+
f'Timestamp cannot be converted within implementation bounds'
507+
)
506508
elif obj.dts.year == 2262:
507509
if not (obj.value > 0):
508-
raise OutOfBoundsDatetime
510+
raise OutOfBoundsDatetime(
511+
f'Timestamp cannot be converted within implementation bounds'
512+
)
509513

510514

511515
# ----------------------------------------------------------------------

pandas/tests/scalar/timestamp/test_timezones.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ def test_tz_localize_pushes_out_of_bounds(self):
2727
assert pac.value > Timestamp.min.value
2828
pac.tz_convert("Asia/Tokyo") # tz_convert doesn't change value
2929
with pytest.raises(OutOfBoundsDatetime):
30-
Timestamp.min.tz_localize("Asia/Tokyo")
30+
Timestamp.min.tz_localize(
31+
"Asia/Tokyo",
32+
match="Timestamp cannot be converted within implementation bounds",
33+
)
3134

3235
# tz_localize that pushes away from the boundary is OK
3336
tokyo = Timestamp.max.tz_localize("Asia/Tokyo")
3437
assert tokyo.value < Timestamp.max.value
3538
tokyo.tz_convert("US/Pacific") # tz_convert doesn't change value
3639
with pytest.raises(OutOfBoundsDatetime):
37-
Timestamp.max.tz_localize("US/Pacific")
40+
Timestamp.max.tz_localize(
41+
"US/Pacific",
42+
match="Timestamp cannot be converted within implementation bounds",
43+
)
3844

3945
def test_tz_localize_ambiguous_bool(self):
4046
# make sure that we are correctly accepting bool values as ambiguous

0 commit comments

Comments
 (0)