]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add a warning message about PyOS_snprintf (GH-95993)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 7 Oct 2022 20:36:21 +0000 (13:36 -0700)
committerGitHub <noreply@github.com>
Fri, 7 Oct 2022 20:36:21 +0000 (13:36 -0700)
(cherry picked from commit c7b220499662f0c7a4cae51e33372f92ca7b1ee9)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Doc/c-api/conversion.rst
Python/mysnprintf.c

index 9b9c4ffa4d0343bf45dc4f36f099c6f08f420776..fdb321fe7ab3f24effc12bc909964b90e63a7d86 100644 (file)
@@ -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:
 
index cd69198011e3c9baba693200c6ddecd46cc8a395..2a505d14f82c99ca05d58f53ab80dd2e80d9e0ca 100644 (file)
@@ -9,6 +9,7 @@
    would have been written had the buffer not been too small, and to set
    the 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.