Skip to content

Commit d61dda5

Browse files
authored
gh-129813, PEP 782: Soft deprecate _PyBytes_Resize() (#138964)
Soft deprecate _PyBytes_Resize() and PyBytes_FromStringAndSize(NULL, size).
1 parent ed75160 commit d61dda5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Doc/c-api/bytes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ called with a non-bytes parameter.
4747
*len* on success, and ``NULL`` on failure. If *v* is ``NULL``, the contents of
4848
the bytes object are uninitialized.
4949
50+
.. deprecated:: 3.15
51+
``PyBytes_FromStringAndSize(NULL, len)`` is :term:`soft deprecated`,
52+
use the :c:type:`PyBytesWriter` API instead.
53+
5054
5155
.. c:function:: PyObject* PyBytes_FromFormat(const char *format, ...)
5256
@@ -220,6 +224,11 @@ called with a non-bytes parameter.
220224
*\*bytes* is set to ``NULL``, :exc:`MemoryError` is set, and ``-1`` is
221225
returned.
222226
227+
.. deprecated:: 3.15
228+
The function is :term:`soft deprecated`,
229+
use the :c:type:`PyBytesWriter` API instead.
230+
231+
223232
PyBytesWriter
224233
-------------
225234

Doc/whatsnew/3.15.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,11 @@ Deprecated C APIs
774774
signed integer type of the same size is now deprecated.
775775
(Contributed by Serhiy Storchaka in :gh:`132629`.)
776776

777+
* :c:func:`PyBytes_FromStringAndSize(NULL, len) <PyBytes_FromStringAndSize>`
778+
and :c:func:`_PyBytes_Resize` are :term:`soft deprecated`,
779+
use the :c:type:`PyBytesWriter` API instead.
780+
(Contributed by Victor Stinner in :gh:`129813`.)
781+
777782
* Deprecate :c:member:`~PyComplexObject.cval` field of the the
778783
:c:type:`PyComplexObject` type.
779784
Use :c:func:`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex`

0 commit comments

Comments
 (0)