]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-146143: Fix the PyUnicodeWriter_WriteUCS4() signature (GH-146144)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 19 Mar 2026 08:23:01 +0000 (10:23 +0200)
committerGitHub <noreply@github.com>
Thu, 19 Mar 2026 08:23:01 +0000 (08:23 +0000)
It now accepts a pointer to constant buffer of Py_UCS4.

Doc/c-api/unicode.rst
Include/cpython/unicodeobject.h
Misc/NEWS.d/next/C_API/2026-03-18-23-44-29.gh-issue-146143.pwIrJq.rst [new file with mode: 0644]
Objects/unicodeobject.c

index 7e9346ea9f7c6d50444043f3003fed7c70bb77d5..3a9b34b592268ad2d20b5ebf4f100992b1bca997 100644 (file)
@@ -1867,7 +1867,7 @@ object.
    On success, return ``0``.
    On error, set an exception, leave the writer unchanged, and return ``-1``.
 
-.. c:function:: int PyUnicodeWriter_WriteUCS4(PyUnicodeWriter *writer, Py_UCS4 *str, Py_ssize_t size)
+.. c:function:: int PyUnicodeWriter_WriteUCS4(PyUnicodeWriter *writer, const Py_UCS4 *str, Py_ssize_t size)
 
    Writer the UCS4 string *str* into *writer*.
 
index 631a6570658410891024204cc68db33f62be7cb7..ea91f4158eb3929c227b51d4f0505dc33be31220 100644 (file)
@@ -496,7 +496,7 @@ PyAPI_FUNC(int) PyUnicodeWriter_WriteWideChar(
     Py_ssize_t size);
 PyAPI_FUNC(int) PyUnicodeWriter_WriteUCS4(
     PyUnicodeWriter *writer,
-    Py_UCS4 *str,
+    const Py_UCS4 *str,
     Py_ssize_t size);
 
 PyAPI_FUNC(int) PyUnicodeWriter_WriteStr(
diff --git a/Misc/NEWS.d/next/C_API/2026-03-18-23-44-29.gh-issue-146143.pwIrJq.rst b/Misc/NEWS.d/next/C_API/2026-03-18-23-44-29.gh-issue-146143.pwIrJq.rst
new file mode 100644 (file)
index 0000000..930d90f
--- /dev/null
@@ -0,0 +1,2 @@
+:c:func:`PyUnicodeWriter_WriteUCS4` now accepts a pointer to a constant buffer
+of ``Py_UCS4``.
index dd2482ca653fb16f52deeebecfb3740bba6d9209..d51a95c69a93b3750b6dcd8487b1d8b1a026ae2a 100644 (file)
@@ -2224,7 +2224,7 @@ _PyUnicode_FromUCS4(const Py_UCS4 *u, Py_ssize_t size)
 
 int
 PyUnicodeWriter_WriteUCS4(PyUnicodeWriter *pub_writer,
-                          Py_UCS4 *str,
+                          const Py_UCS4 *str,
                           Py_ssize_t size)
 {
     _PyUnicodeWriter *writer = (_PyUnicodeWriter*)pub_writer;