Skip to content

Docs: C API: Clarify what happens when null bytes are passed to PyUnicode_AsUTF8 #127458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 20, 2025
7 changes: 7 additions & 0 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,13 @@ These are the UTF-8 codec APIs:

As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size.

.. note::

This function does not handle null bytes inside of *unicode*, so the length of the
returned string (from ``strlen()``) could be smaller than the length of the
passed unicode object, if the string contained embedded null characters. Prefer
:c:func:`PyUnicode_AsUTF8AndSize` when dealing with user input.

.. versionadded:: 3.3

.. versionchanged:: 3.7
Expand Down
Loading