]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-148250: Mention str subclasses in PyUnicodeWriter_WriteStr() doc (#148251)
authorVictor Stinner <vstinner@python.org>
Thu, 9 Apr 2026 11:53:10 +0000 (13:53 +0200)
committerGitHub <noreply@github.com>
Thu, 9 Apr 2026 11:53:10 +0000 (13:53 +0200)
Doc/c-api/unicode.rst

index 679823948e73b52d237e750c5e1916746e3b9470..059a7ef399ae0f5f583b343636fecf9f13b0736c 100644 (file)
@@ -1881,6 +1881,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*.