From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 9 Apr 2026 11:59:06 +0000 (+0200) Subject: [3.14] gh-148250: Mention str subclasses in PyUnicodeWriter_WriteStr() doc (GH-148251... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=88fc1e60038378fddb4db67a7dc7427fe9982a29;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-148250: Mention str subclasses in PyUnicodeWriter_WriteStr() doc (GH-148251) (#148293) gh-148250: Mention str subclasses in PyUnicodeWriter_WriteStr() doc (GH-148251) (cherry picked from commit 8c524503cd728d609d63d9024a9e2c418ba71f40) Co-authored-by: Victor Stinner --- diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 53a13e80944c..ab58a64647ac 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -1868,6 +1868,10 @@ object. On success, return ``0``. On error, set an exception, leave the writer unchanged, and return ``-1``. + To write a :class:`str` subclass which overrides the :meth:`~object.__str__` + method, :c:func:`PyUnicode_FromObject` can be used to get the original + string. + .. c:function:: int PyUnicodeWriter_WriteRepr(PyUnicodeWriter *writer, PyObject *obj) Call :c:func:`PyObject_Repr` on *obj* and write the output into *writer*.