]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-129813, PEP 782: Soft deprecate _PyBytes_Resize() (#138964)
authorVictor Stinner <vstinner@python.org>
Tue, 16 Sep 2025 08:38:43 +0000 (09:38 +0100)
committerGitHub <noreply@github.com>
Tue, 16 Sep 2025 08:38:43 +0000 (10:38 +0200)
Soft deprecate _PyBytes_Resize() and
PyBytes_FromStringAndSize(NULL, size).

Doc/c-api/bytes.rst
Doc/whatsnew/3.15.rst

index 8cc935cd06659c80d0fe45ef9aff07a21ea2929c..89ff070f1c5cf7fef396cee7cc3c09cbab1ff736 100644 (file)
@@ -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
 -------------
 
index ed44558c1d3beb4ed7522dddf4964dcaf8b5dc64..0775edc6830f575f692aaa6fb4e18871231a4585 100644 (file)
@@ -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) <PyBytes_FromStringAndSize>`
+  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`