Skip to content

Commit 9ffb022

Browse files
committed
Update PyUnicodeWriter for Python 3.16.0a2
* Test PyUnicodeWriter on Python 3.14 and newer. * Add python3.16 to runtests.py.
1 parent 01785ff commit 9ffb022

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎runtests.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
"python3.14t",
3939
"python3.15",
4040
"python3.15t",
41+
"python3.16",
42+
"python3.16t",
4143

4244
# PyPy
4345
"pypy3",

‎tests/test_pythoncapi_compat_cext.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,8 +1896,10 @@ test_get_constant(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
18961896
}
18971897

18981898

1899-
#if (PY_VERSION_HEX < _Py_PACK_VERSION(3, 14) && PY_VERSION_HEX >= _Py_PACK_VERSION(3, 6) \
1900-
&& !defined(PYPY_VERSION) && !defined(Py_LIMITED_API))
1899+
// PyUnicodeWriter was added to the limited C API 3.16.0a2.
1900+
#if (!defined(PYPY_VERSION) \
1901+
&& (!defined(Py_LIMITED_API) \
1902+
|| Py_LIMITED_API+0 >= _Py_PACK_FULL_VERSION(3, 16, 0, 0xA, 2)))
19011903
#define TEST_UNICODEWRITER 1
19021904

19031905
static PyObject *
@@ -1951,7 +1953,8 @@ test_unicodewriter(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
19511953
}
19521954

19531955
// test PyUnicodeWriter_WriteUCS4()
1954-
if (PyUnicodeWriter_WriteUCS4(writer, ucs4, Py_ARRAY_LENGTH(ucs4)) < 0) {
1956+
// Python 3.14 expects "Py_UCS4*", Python 3.15 expects "const Py_UCS4*"
1957+
if (PyUnicodeWriter_WriteUCS4(writer, (Py_UCS4*)ucs4, Py_ARRAY_LENGTH(ucs4)) < 0) {
19551958
goto error;
19561959
}
19571960
if (PyUnicodeWriter_WriteChar(writer, ' ') < 0) {

0 commit comments

Comments
 (0)