Skip to content

Commit 22e9faf

Browse files
miss-islingtonZeroIntensityStanFromIrelandtomasr8vstinner
authored
[3.13] Docs C API: Clarify what happens when null bytes are passed to PyUnicode_AsUTF8 (GH-127458) (#129080)
Docs C API: Clarify what happens when null bytes are passed to `PyUnicode_AsUTF8` (GH-127458) (cherry picked from commit e792f4b) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Stan U. <[email protected]> Co-authored-by: Tomas R. <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
1 parent 2f8eefe commit 22e9faf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Doc/c-api/unicode.rst

+9
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,15 @@ These are the UTF-8 codec APIs:
10541054
10551055
As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size.
10561056
1057+
.. warning::
1058+
1059+
This function does not have any special behavior for
1060+
`null characters <https://en.wikipedia.org/wiki/Null_character>`_ embedded within
1061+
*unicode*. As a result, strings containing null characters will remain in the returned
1062+
string, which some C functions might interpret as the end of the string, leading to
1063+
truncation. If truncation is an issue, it is recommended to use :c:func:`PyUnicode_AsUTF8AndSize`
1064+
instead.
1065+
10571066
.. versionadded:: 3.3
10581067
10591068
.. versionchanged:: 3.7

0 commit comments

Comments
 (0)