https://github.com/python/cpython/commit/becd7a967f36248e0090010fbd04885170df3e7a
commit: becd7a967f36248e0090010fbd04885170df3e7a
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-03-19T08:23:01Z
summary:
gh-146143: Fix the PyUnicodeWriter_WriteUCS4() signature (GH-146144)
It now accepts a pointer to constant buffer of Py_UCS4.
files:
A Misc/NEWS.d/next/C_API/2026-03-18-23-44-29.gh-issue-146143.pwIrJq.rst
M Doc/c-api/unicode.rst
M Include/cpython/unicodeobject.h
M Objects/unicodeobject.c
diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst
index 7e9346ea9f7c6d..3a9b34b592268a 100644
--- a/Doc/c-api/unicode.rst
+++ b/Doc/c-api/unicode.rst
@@ -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*.
diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h
index 631a6570658410..ea91f4158eb392 100644
--- a/Include/cpython/unicodeobject.h
+++ b/Include/cpython/unicodeobject.h
@@ -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
index 00000000000000..930d90ff9a2675
--- /dev/null
+++ b/Misc/NEWS.d/next/C_API/2026-03-18-23-44-29.gh-issue-146143.pwIrJq.rst
@@ -0,0 +1,2 @@
+:c:func:`PyUnicodeWriter_WriteUCS4` now accepts a pointer to a constant buffer
+of ``Py_UCS4``.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index dd2482ca653fb1..d51a95c69a93b3 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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;
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]