Skip to content

Commit 718e12e

Browse files
authored
Add CI builds for free-threaded Python versions (#150)
Add missing error-checking in PyLong export tests.
1 parent 5e31710 commit 718e12e

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ jobs:
2727
- "3.11"
2828
- "3.12"
2929
- "3.13"
30+
- "3.13t"
3031
# CPython 3.14 final is scheduled for October 2025:
3132
# https://peps.python.org/pep-0719/
3233
- "3.14"
34+
- "3.14t"
3335

3436
# PyPy versions:
3537
# - https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md
@@ -68,6 +70,8 @@ jobs:
6870
python: "3.12"
6971
- os: windows-latest
7072
python: "3.13"
73+
- os: windows-latest
74+
python: "3.13t"
7175

7276
# macOS
7377
# Python 3.9 is the oldest version available on macOS/arm64.
@@ -81,6 +85,8 @@ jobs:
8185
python: "3.12"
8286
- os: macos-latest
8387
python: "3.13"
88+
- os: macos-latest
89+
python: "3.13t"
8490

8591
# Ubuntu: test deadsnakes Python versions which are not supported by
8692
# GHA python-versions.

tests/test_pythoncapi_compat_cext.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,29 +1432,48 @@ test_long_api(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
14321432
PyLongWriter *writer;
14331433
static PyLongExport long_export;
14341434

1435-
writer = PyLongWriter_Create(1, 1, (void**)&digits);
1435+
writer = PyLongWriter_Create(1, 1, (void **)&digits);
1436+
if (writer == NULL) {
1437+
return NULL;
1438+
}
14361439
PyLongWriter_Discard(writer);
14371440

1438-
writer = PyLongWriter_Create(1, 1, (void**)&digits);
1441+
writer = PyLongWriter_Create(1, 1, (void **)&digits);
1442+
if (writer == NULL) {
1443+
return NULL;
1444+
}
14391445
digits[0] = 123;
14401446
obj = PyLongWriter_Finish(writer);
1447+
if (obj == NULL) {
1448+
return NULL;
1449+
}
14411450

14421451
check_int(obj, -123);
1443-
PyLong_Export(obj, &long_export);
1452+
if (PyLong_Export(obj, &long_export) < 0) {
1453+
return NULL;
1454+
}
14441455
assert(long_export.value == -123);
14451456
assert(long_export.digits == NULL);
14461457
PyLong_FreeExport(&long_export);
14471458
Py_DECREF(obj);
14481459

1449-
writer = PyLongWriter_Create(0, 5, (void**)&digits);
1460+
writer = PyLongWriter_Create(0, 5, (void **)&digits);
1461+
if (writer == NULL) {
1462+
return NULL;
1463+
}
14501464
digits[0] = 1;
14511465
digits[1] = 0;
14521466
digits[2] = 0;
14531467
digits[3] = 0;
14541468
digits[4] = 1;
14551469
obj = PyLongWriter_Finish(writer);
1470+
if (obj == NULL) {
1471+
return NULL;
1472+
}
14561473

1457-
PyLong_Export(obj, &long_export);
1474+
if (PyLong_Export(obj, &long_export) < 0) {
1475+
return NULL;
1476+
}
14581477
assert(long_export.value == 0);
14591478
digits = (digit*)long_export.digits;
14601479
assert(digits[0] == 1);

0 commit comments

Comments
 (0)