]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Docs C API: Clarify what happens when null bytes are passed to `PyUnicode_AsUTF8...
authorPeter Bierma <zintensitydev@gmail.com>
Mon, 20 Jan 2025 15:54:29 +0000 (10:54 -0500)
committerGitHub <noreply@github.com>
Mon, 20 Jan 2025 15:54:29 +0000 (16:54 +0100)
Co-authored-by: Stan U. <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Doc/c-api/unicode.rst

index f19b86a8dbfb66ab2f65e2796aafda00a7d653c7..94110d48ed7d85ffc9c53ef21d1a91de848c55f0 100644 (file)
@@ -1054,6 +1054,15 @@ These are the UTF-8 codec APIs:
 
    As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size.
 
+   .. warning::
+
+      This function does not have any special behavior for
+      `null characters <https://en.wikipedia.org/wiki/Null_character>`_ embedded within
+      *unicode*. As a result, strings containing null characters will remain in the returned
+      string, which some C functions might interpret as the end of the string, leading to
+      truncation. If truncation is an issue, it is recommended to use :c:func:`PyUnicode_AsUTF8AndSize`
+      instead.
+
    .. versionadded:: 3.3
 
    .. versionchanged:: 3.7