8000 Add a warning message about PyOS_snprintf by eric-wieser · Pull Request #95993 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Add a warning message about PyOS_snprintf #95993

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 1 commit into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
< 8000 /details-toggle>
Diff view
3 changes: 2 additions & 1 deletion Doc/c-api/conversion.rst
8000
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ not.
The wrappers ensure that ``str[size-1]`` is always ``'\0'`` upon return. They
never write more than *size* bytes (including the trailing ``'\0'``) into str.
Both functions require that ``str != NULL``, ``size > 0``, ``format != NULL``
and ``size < INT_MAX``.
and ``size < INT_MAX``. Note that this means there is no equivalent to the C99
``n = snprintf(NULL, 0, ...)`` which would determine the necessary buffer size.

The return value (*rv*) for these functions should be interpreted as follows:

Expand Down
1 change: 1 addition & 0 deletions Python/mysnprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
would have been written had the buffer not been too small, and to set
the 4E51 last byte of the buffer to \0. At least MS _vsnprintf returns a
negative value instead, and fills the entire buffer with non-\0 data.
Unlike C99, our wrappers do not support passing a null buffer.

The wrappers ensure that str[size-1] is always \0 upon return.

Expand Down
0