Skip to content

Commit e6cb31a

Browse files
miss-islingtonZeroIntensityStanFromIrelandtomasr8vstinner
authored
[3.12] Docs C API: Clarify what happens when null bytes are passed to PyUnicode_AsUTF8 (GH-127458) (#129081)
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 032058c commit e6cb31a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Doc/c-api/unicode.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,15 @@ These are the UTF-8 codec APIs:
10321032
10331033
As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size.
10341034
1035+
.. warning::
1036+
1037+
This function does not have any special behavior for
1038+
`null characters <https://en.wikipedia.org/wiki/Null_character>`_ embedded within
1039+
*unicode*. As a result, strings containing null characters will remain in the returned
1040+
string, which some C functions might interpret as the end of the string, leading to
1041+
truncation. If truncation is an issue, it is recommended to use :c:func:`PyUnicode_AsUTF8AndSize`
1042+
instead.
1043+
10351044
.. versionadded:: 3.3
10361045
10371046
.. versionchanged:: 3.7

0 commit comments

Comments
 (0)