gh-129559: Add bytearray.resize() (GH-129560)

Add bytearray.resize() which wraps PyByteArray_Resize.

Make negative size passed to resize exception/error rather than crash in optimized builds.
This commit is contained in:
Cody Maloney 2025-02-05 11:33:17 -08:00 committed by GitHub
parent 7d9a22f509
commit 5fb019fc29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 158 additions and 9 deletions

View file

@ -74,6 +74,11 @@ Direct API functions
.. c:function:: int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
Resize the internal buffer of *bytearray* to *len*.
Failure is a ``-1`` return with an exception set.
.. versionchanged:: next
A negative *len* will now result in an exception being set and -1 returned.
Macros
^^^^^^