mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-87193: Support bytes objects with refcount > 1 in _PyBytes_Resize() (GH-117160)
Create a new bytes object and destroy the old one if it has refcount > 1.
This commit is contained in:
parent
01e7405da4
commit
0c1a42cf9c
11 changed files with 123 additions and 30 deletions
|
|
@ -191,10 +191,10 @@ called with a non-bytes parameter.
|
|||
|
||||
.. c:function:: int _PyBytes_Resize(PyObject **bytes, Py_ssize_t newsize)
|
||||
|
||||
A way to resize a bytes object even though it is "immutable". Only use this
|
||||
to build up a brand new bytes object; don't use this if the bytes may already
|
||||
be known in other parts of the code. It is an error to call this function if
|
||||
the refcount on the input bytes object is not one. Pass the address of an
|
||||
Resize a bytes object. *newsize* will be the new length of the bytes object.
|
||||
You can think of it as creating a new bytes object and destroying the old
|
||||
one, only more efficiently.
|
||||
Pass the address of an
|
||||
existing bytes object as an lvalue (it may be written into), and the new size
|
||||
desired. On success, *\*bytes* holds the resized bytes object and ``0`` is
|
||||
returned; the address in *\*bytes* may differ from its input value. If the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue