Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: catch windows py38 OSError #37659

Merged
merged 6 commits into from
Nov 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pandas/_libs/tslibs/tzconversion.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ from cpython.datetime cimport tzinfo
from numpy cimport int64_t


cdef int64_t tz_convert_utc_to_tzlocal(int64_t utc_val, tzinfo tz, bint* fold=*)
cdef int64_t tz_convert_utc_to_tzlocal(
int64_t utc_val, tzinfo tz, bint* fold=*
) except? -1
cpdef int64_t tz_convert_from_utc_single(int64_t val, tzinfo tz)
cdef int64_t tz_localize_to_utc_single(
int64_t val, tzinfo tz, object ambiguous=*, object nonexistent=*
Expand Down
8 changes: 6 additions & 2 deletions pandas/_libs/tslibs/tzconversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ cdef inline str _render_tstamp(int64_t val):
# ----------------------------------------------------------------------
# Timezone Conversion

cdef int64_t tz_convert_utc_to_tzlocal(int64_t utc_val, tzinfo tz, bint* fold=NULL):
cdef int64_t tz_convert_utc_to_tzlocal(
int64_t utc_val, tzinfo tz, bint* fold=NULL
) except? -1:
"""
Parameters
----------
Expand Down Expand Up @@ -549,8 +551,10 @@ cdef inline int64_t _tzlocal_get_offset_components(int64_t val, tzinfo tz,
return int(td.total_seconds() * 1_000_000_000)


# OSError may be thrown by tzlocal on windows at or close to 1970-01-01
# see https://github.com/pandas-dev/pandas/pull/37591#issuecomment-720628241
cdef int64_t _tz_convert_tzlocal_utc(int64_t val, tzinfo tz, bint to_utc=True,
bint* fold=NULL):
bint* fold=NULL) except? -1:
"""
Convert the i8 representation of a datetime from a tzlocal timezone to
UTC, or vice-versa.
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/frame/test_reductions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from datetime import timedelta
from decimal import Decimal

from dateutil.tz import tzlocal
import numpy as np
import pytest

from pandas.compat import is_platform_windows
import pandas.util._test_decorators as td

import pandas as pd
Expand Down Expand Up @@ -1172,6 +1174,12 @@ def test_min_max_dt64_with_NaT(self):
def test_min_max_dt64_with_NaT_skipna_false(self, tz_naive_fixture):
# GH#36907
tz = tz_naive_fixture
if isinstance(tz, tzlocal) and is_platform_windows():
pytest.xfail(
reason="GH#37659 OSError raised within tzlocal bc Windows "
"chokes in times before 1970-01-01"
)

df = DataFrame(
{
"a": [
Expand Down
40 changes: 23 additions & 17 deletions pandas/tests/indexes/datetimes/test_ops.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from datetime import datetime

from dateutil.tz import tzlocal
import numpy as np
import pytest

from pandas.compat import IS64

import pandas as pd
from pandas import (
DateOffset,
Expand Down Expand Up @@ -106,24 +109,27 @@ def test_repeat(self, tz_naive_fixture):
with pytest.raises(ValueError, match=msg):
np.repeat(rng, reps, axis=1)

def test_resolution(self, tz_naive_fixture):
@pytest.mark.parametrize(
"freq,expected",
[
("A", "day"),
("Q", "day"),
("M", "day"),
("D", "day"),
("H", "hour"),
("T", "minute"),
("S", "second"),
("L", "millisecond"),
("U", "microsecond"),
],
)
def test_resolution(self, tz_naive_fixture, freq, expected):
tz = tz_naive_fixture
for freq, expected in zip(
["A", "Q", "M", "D", "H", "T", "S", "L", "U"],
[
"day",
"day",
"day",
"day",
"hour",
"minute",
"second",
"millisecond",
"microsecond",
],
):
idx = pd.date_range(start="2013-04-01", periods=30, freq=freq, tz=tz)
assert idx.resolution == expected
if freq == "A" and not IS64 and isinstance(tz, tzlocal):
pytest.xfail(reason="OverflowError inside tzlocal past 2038")

idx = pd.date_range(start="2013-04-01", periods=30, freq=freq, tz=tz)
assert idx.resolution == expected

def test_value_counts_unique(self, tz_naive_fixture):
tz = tz_naive_fixture
Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/tseries/offsets/test_offsets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import date, datetime, time as dt_time, timedelta
from typing import Dict, List, Optional, Tuple, Type

from dateutil.tz import tzlocal
import numpy as np
import pytest

Expand All @@ -14,6 +15,7 @@
import pandas._libs.tslibs.offsets as liboffsets
from pandas._libs.tslibs.offsets import ApplyTypeError, _get_offset, _offset_map
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
from pandas.compat import IS64
from pandas.compat.numpy import np_datetime64_compat
from pandas.errors import PerformanceWarning

Expand Down Expand Up @@ -129,6 +131,8 @@ def test_apply_out_of_range(self, tz_naive_fixture):
tz = tz_naive_fixture
if self._offset is None:
return
if isinstance(tz, tzlocal) and not IS64:
pytest.xfail(reason="OverflowError inside tzlocal past 2038")

# try to create an out-of-bounds result timestamp; if we can't create
# the offset skip
Expand Down