]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-148250: Mention str subclasses in PyUnicodeWriter_WriteStr() doc (GH-148251...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 9 Apr 2026 11:59:06 +0000 (13:59 +0200)
committerGitHub <noreply@github.com>
Thu, 9 Apr 2026 11:59:06 +0000 (11:59 +0000)
gh-148250: Mention str subclasses in PyUnicodeWriter_WriteStr() doc (GH-148251)
(cherry picked from commit 8c524503cd728d609d63d9024a9e2c418ba71f40)

Co-authored-by: Victor Stinner <vstinner@python.org>
Doc/c-api/unicode.rst

index 53a13e80944c70382d7fd05023cc4caff4d324b8..ab58a64647ac610c89a1a2e75089adc0e7a3f64f 100644 (file)
@@ -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*.