Skip to content

Commit e322603

Browse files
author
MomIsBestFriend
committed
Put fromisocalendar in PY38 block
1 parent e4696b1 commit e322603

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pandas/_libs/tslibs/nattype.pyx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ from pandas._libs.tslibs.util cimport (
1919
get_nat, is_integer_object, is_float_object, is_datetime64_object,
2020
is_timedelta64_object)
2121

22+
import pandas.compat as compat
23+
2224
# ----------------------------------------------------------------------
2325
# Constants
2426
nat_strings = {'NaT', 'nat', 'NAT', 'nan', 'NaN', 'NAN'}
@@ -426,9 +428,10 @@ class NaTType(_NaT):
426428
toordinal = _make_error_func('toordinal', datetime)
427429
tzname = _make_error_func('tzname', datetime)
428430
utcoffset = _make_error_func('utcoffset', datetime)
429-
fromisocalendar = _make_error_func(
430-
'fromisocalendar', datetime.fromisocalendar.__doc__
431-
)
431+
432+
# "fromisocalendar" was introduced in 3.8
433+
if compat.PY38:
434+
fromisocalendar = _make_error_func('fromisocalendar', datetime)
432435

433436
# ----------------------------------------------------------------------
434437
# The remaining methods have docstrings copy/pasted from the analogous

pandas/tests/scalar/test_nat.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ def test_round_nat(klass, method, freq):
141141
],
142142
)
143143
def test_nat_methods_raise(method):
144+
# "fromisocalendar" was introduced in 3.8
145+
if method == "fromisocalendar" and not compat.PY38:
146+
method.remove("fromisocalendar")
147+
144148
# see gh-9513, gh-17329
145149
msg = f"NaTType does not support {method}"
146150

@@ -299,6 +303,10 @@ def test_overlap_public_nat_methods(klass, expected):
299303
if klass is Timestamp and not compat.PY37:
300304
expected.remove("fromisoformat")
301305

306+
# "fromisocalendar" was introduced in 3.8
307+
if klass is Timestamp and not compat.PY38:
308+
expected.remove("fromisocalendar")
309+
302310
assert _get_overlap_public_nat_methods(klass) == expected
303311

304312

0 commit comments

Comments
 (0)