From: Victor Stinner Date: Tue, 16 Sep 2025 08:38:43 +0000 (+0100) Subject: gh-129813, PEP 782: Soft deprecate _PyBytes_Resize() (#138964) X-Git-Tag: v3.15.0a1~338 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d61dda52bac93927829f853c952485e2b0c42899;p=thirdparty%2FPython%2Fcpython.git gh-129813, PEP 782: Soft deprecate _PyBytes_Resize() (#138964) Soft deprecate _PyBytes_Resize() and PyBytes_FromStringAndSize(NULL, size). --- diff --git a/Doc/c-api/bytes.rst b/Doc/c-api/bytes.rst index 8cc935cd0665..89ff070f1c5c 100644 --- a/Doc/c-api/bytes.rst +++ b/Doc/c-api/bytes.rst @@ -47,6 +47,10 @@ called with a non-bytes parameter. *len* on success, and ``NULL`` on failure. If *v* is ``NULL``, the contents of the bytes object are uninitialized. + .. deprecated:: 3.15 + ``PyBytes_FromStringAndSize(NULL, len)`` is :term:`soft deprecated`, + use the :c:type:`PyBytesWriter` API instead. + .. c:function:: PyObject* PyBytes_FromFormat(const char *format, ...) @@ -220,6 +224,11 @@ called with a non-bytes parameter. *\*bytes* is set to ``NULL``, :exc:`MemoryError` is set, and ``-1`` is returned. + .. deprecated:: 3.15 + The function is :term:`soft deprecated`, + use the :c:type:`PyBytesWriter` API instead. + + PyBytesWriter ------------- diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index ed44558c1d3b..0775edc6830f 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -774,6 +774,11 @@ Deprecated C APIs signed integer type of the same size is now deprecated. (Contributed by Serhiy Storchaka in :gh:`132629`.) +* :c:func:`PyBytes_FromStringAndSize(NULL, len) ` + and :c:func:`_PyBytes_Resize` are :term:`soft deprecated`, + use the :c:type:`PyBytesWriter` API instead. + (Contributed by Victor Stinner in :gh:`129813`.) + * Deprecate :c:member:`~PyComplexObject.cval` field of the the :c:type:`PyComplexObject` type. Use :c:func:`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex`