Skip to content

Commit 24fa9dc

Browse files
lysnikolaoulithomas1
authored andcommitted
ENH: Fix Python 3.13 test failures & enable CI (pandas-dev#59065)
* ENH: Fix Python 3.13 test failures & enable CI x-ref pandas-dev#58734 Co-authored-by: Thomas Li <[email protected]> * Cast npy_intp to int to fix Windows CI --------- Co-authored-by: Thomas Li <[email protected]>
1 parent fb0b19f commit 24fa9dc

File tree

8 files changed

+24
-13
lines changed

8 files changed

+24
-13
lines changed

.github/workflows/unit-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ jobs:
329329
# To freeze this file, uncomment out the ``if: false`` condition, and migrate the jobs
330330
# to the corresponding posix/windows-macos/sdist etc. workflows.
331331
# Feel free to modify this comment as necessary.
332-
if: false # Uncomment this to freeze the workflow, comment it to unfreeze
332+
# if: false # Uncomment this to freeze the workflow, comment it to unfreeze
333333
defaults:
334334
run:
335335
shell: bash -eou pipefail {0}
@@ -361,7 +361,7 @@ jobs:
361361
- name: Set up Python Dev Version
362362
uses: actions/setup-python@v5
363363
with:
364-
python-version: '3.12-dev'
364+
python-version: '3.13-dev'
365365

366366
- name: Build Environment
367367
run: |

pandas/_libs/src/vendored/ujson/python/objToJSON.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ static void NpyArr_iterBegin(JSOBJ _obj, JSONTypeContext *tc) {
410410
npyarr->type_num = PyArray_DESCR(obj)->type_num;
411411

412412
if (GET_TC(tc)->transpose) {
413-
npyarr->dim = PyArray_DIM(obj, npyarr->ndim);
414-
npyarr->stride = PyArray_STRIDE(obj, npyarr->ndim);
413+
npyarr->dim = PyArray_DIM(obj, (int)npyarr->ndim);
414+
npyarr->stride = PyArray_STRIDE(obj, (int)npyarr->ndim);
415415
npyarr->stridedim = npyarr->ndim;
416416
npyarr->index[npyarr->ndim] = 0;
417417
npyarr->inc = -1;
@@ -452,8 +452,8 @@ static void NpyArrPassThru_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
452452
return;
453453
}
454454
const PyArrayObject *arrayobj = (const PyArrayObject *)npyarr->array;
455-
npyarr->dim = PyArray_DIM(arrayobj, npyarr->stridedim);
456-
npyarr->stride = PyArray_STRIDE(arrayobj, npyarr->stridedim);
455+
npyarr->dim = PyArray_DIM(arrayobj, (int)npyarr->stridedim);
456+
npyarr->stride = PyArray_STRIDE(arrayobj, (int)npyarr->stridedim);
457457
npyarr->dataptr += npyarr->stride;
458458

459459
NpyArr_freeItemValue(obj, tc);
@@ -524,8 +524,8 @@ static int NpyArr_iterNext(JSOBJ _obj, JSONTypeContext *tc) {
524524
}
525525
const PyArrayObject *arrayobj = (const PyArrayObject *)npyarr->array;
526526

527-
npyarr->dim = PyArray_DIM(arrayobj, npyarr->stridedim);
528-
npyarr->stride = PyArray_STRIDE(arrayobj, npyarr->stridedim);
527+
npyarr->dim = PyArray_DIM(arrayobj, (int)npyarr->stridedim);
528+
npyarr->stride = PyArray_STRIDE(arrayobj, (int)npyarr->stridedim);
529529
npyarr->index[npyarr->stridedim] = 0;
530530

531531
((PyObjectEncoder *)tc->encoder)->npyCtxtPassthru = npyarr;

pandas/_libs/tslibs/offsets.pyx

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

4963-
if is_period and not hasattr(result, "_period_dtype_code"):
4963+
try:
4964+
has_period_dtype_code = hasattr(result, "_period_dtype_code")
4965+
except ValueError:
4966+
has_period_dtype_code = False
4967+
4968+
if is_period and not has_period_dtype_code:
49644969
if isinstance(freq, str):
49654970
raise ValueError(f"{result.name} is not supported as period frequency")
49664971
else:

pandas/tests/groupby/test_groupby.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2816,7 +2816,9 @@ def test_rolling_wrong_param_min_period():
28162816
test_df = DataFrame([name_l, val_l]).T
28172817
test_df.columns = ["name", "val"]
28182818

2819-
result_error_msg = r"__init__\(\) got an unexpected keyword argument 'min_period'"
2819+
result_error_msg = (
2820+
r"^[a-zA-Z._]*\(\) got an unexpected keyword argument 'min_period'"
2821+
)
28202822
with pytest.raises(TypeError, match=result_error_msg):
28212823
test_df.groupby("name")["val"].rolling(window=2, min_period=1).sum()
28222824

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
@@ -485,7 +485,10 @@ def test_warning_missing_utf_bom(self, encoding, compression_):
485485
df.to_csv(path, compression=compression_, encoding=encoding)
486486

487487
# reading should fail (otherwise we wouldn't need the warning)
488-
msg = r"UTF-\d+ stream does not start with BOM"
488+
msg = (
489+
r"UTF-\d+ stream does not start with BOM|"
490+
r"'utf-\d+' codec can't decode byte"
491+
)
489492
with pytest.raises(UnicodeError, match=msg):
490493
pd.read_csv(path, compression=compression_, encoding=encoding)
491494

pandas/tests/io/xml/test_xml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ def test_utf16_encoding(xml_baby_names, parser):
10441044
UnicodeError,
10451045
match=(
10461046
"UTF-16 stream does not start with BOM|"
1047-
"'utf-16-le' codec can't decode byte"
1047+
"'utf-16(-le)?' codec can't decode byte"
10481048
),
10491049
):
10501050
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
@@ -622,6 +622,7 @@ def test_td_floordiv_invalid_scalar(self):
622622
[
623623
r"Invalid dtype datetime64\[D\] for __floordiv__",
624624
"'dtype' is an invalid keyword argument for this function",
625+
"this function got an unexpected keyword argument 'dtype'",
625626
r"ufunc '?floor_divide'? cannot use operands with types",
626627
]
627628
)

0 commit comments

Comments
 (0)