Skip to content

Commit c207a3c

Browse files
ENH: Fix Python 3.13 test failures & enable CI
x-ref pandas-dev#58734 Co-authored-by: Thomas Li <[email protected]>
1 parent dd87dd3 commit c207a3c

File tree

7 files changed

+16
-7
lines changed

7 files changed

+16
-7
lines changed

.github/workflows/unit-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ jobs:
300300
# To freeze this file, uncomment out the ``if: false`` condition, and migrate the jobs
301301
# to the corresponding posix/windows-macos/sdist etc. workflows.
302302
# Feel free to modify this comment as necessary.
303-
if: false # Uncomment this to freeze the workflow, comment it to unfreeze
303+
# if: false # Uncomment this to freeze the workflow, comment it to unfreeze
304304
defaults:
305305
run:
306306
shell: bash -eou pipefail {0}
@@ -332,7 +332,7 @@ jobs:
332332
- name: Set up Python Dev Version
333333
uses: actions/setup-python@v5
334334
with:
335-
python-version: '3.12-dev'
335+
python-version: '3.13-dev'
336336

337337
- name: Build Environment
338338
run: |

pandas/_libs/tslibs/offsets.pyx

+6-1
Original file line numberDiff line numberDiff line change
@@ -4948,7 +4948,12 @@ cpdef to_offset(freq, bint is_period=False):
49484948
if result is None:
49494949
raise ValueError(INVALID_FREQ_ERR_MSG.format(freq))
49504950

4951-
if is_period and not hasattr(result, "_period_dtype_code"):
4951+
try:
4952+
has_period_dtype_code = hasattr(result, "_period_dtype_code")
4953+
except ValueError:
4954+
has_period_dtype_code = False
4955+
4956+
if is_period and not has_period_dtype_code:
49524957
if isinstance(freq, str):
49534958
raise ValueError(f"{result.name} is not supported as period frequency")
49544959
else:

pandas/tests/groupby/test_groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2445,7 +2445,7 @@ def test_rolling_wrong_param_min_period():
24452445
test_df.columns = ["name", "val"]
24462446

24472447
result_error_msg = (
2448-
r"^[a-zA-Z._]*\(\) got an unexpected keyword argument 'min_period'$"
2448+
r"^[a-zA-Z._]*\(\) got an unexpected keyword argument 'min_period'"
24492449
)
24502450
with pytest.raises(TypeError, match=result_error_msg):
24512451
test_df.groupby("name")["val"].rolling(window=2, min_period=1).sum()

pandas/tests/io/parser/test_dialect.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def custom_dialect():
2626
"escapechar": "~",
2727
"delimiter": ":",
2828
"skipinitialspace": False,
29-
"quotechar": "~",
29+
"quotechar": "`",
3030
"quoting": 3,
3131
}
3232
return dialect_name, dialect_kwargs

pandas/tests/io/test_common.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,10 @@ def test_warning_missing_utf_bom(self, encoding, compression_):
474474
df.to_csv(path, compression=compression_, encoding=encoding)
475475

476476
# reading should fail (otherwise we wouldn't need the warning)
477-
msg = r"UTF-\d+ stream does not start with BOM"
477+
msg = (
478+
r"UTF-\d+ stream does not start with BOM|"
479+
r"'utf-\d+' codec can't decode byte"
480+
)
478481
with pytest.raises(UnicodeError, match=msg):
479482
pd.read_csv(path, compression=compression_, encoding=encoding)
480483

pandas/tests/io/xml/test_xml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ def test_utf16_encoding(xml_baby_names, parser):
10381038
UnicodeError,
10391039
match=(
10401040
"UTF-16 stream does not start with BOM|"
1041-
"'utf-16-le' codec can't decode byte"
1041+
"'utf-16(-le)?' codec can't decode byte"
10421042
),
10431043
):
10441044
read_xml(xml_baby_names, encoding="UTF-16", parser=parser)

pandas/tests/scalar/timedelta/test_arithmetic.py

+1
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ def test_td_floordiv_invalid_scalar(self):
623623
[
624624
r"Invalid dtype datetime64\[D\] for __floordiv__",
625625
"'dtype' is an invalid keyword argument for this function",
626+
"this function got an unexpected keyword argument 'dtype'",
626627
r"ufunc '?floor_divide'? cannot use operands with types",
627628
]
628629
)

0 commit comments

Comments
 (0)