Skip to content

Commit 88fc1e6

Browse files
[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 8c52450) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent d31a16e commit 88fc1e6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Doc/c-api/unicode.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,10 @@ object.
18681868
On success, return ``0``.
18691869
On error, set an exception, leave the writer unchanged, and return ``-1``.
18701870
1871+
To write a :class:`str` subclass which overrides the :meth:`~object.__str__`
1872+
method, :c:func:`PyUnicode_FromObject` can be used to get the original
1873+
string.
1874+
18711875
.. c:function:: int PyUnicodeWriter_WriteRepr(PyUnicodeWriter *writer, PyObject *obj)
18721876
18731877
Call :c:func:`PyObject_Repr` on *obj* and write the output into *writer*.

0 commit comments

Comments
 (0)