Skip to content
Merged
Prev Previous commit
Next Next commit
Merge branch 'main' into fix-issue-129107
  • Loading branch information
tom-pytel committed Feb 12, 2025
commit 6314eb4d3cdc9900ab7407110764efc3912b393c
25 changes: 25 additions & 0 deletions Objects/bytearrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,31 @@ bytearray_removesuffix_impl(PyByteArrayObject *self, Py_buffer *suffix)
}


/*[clinic input]
bytearray.resize
size: Py_ssize_t
New size to resize to..
/
Resize the internal buffer of bytearray to len.
[clinic start generated code]*/

static PyObject *
bytearray_resize_impl(PyByteArrayObject *self, Py_ssize_t size)
/*[clinic end generated code: output=f73524922990b2d9 input=75fd4d17c4aa47d3]*/
{
Py_ssize_t start_size = PyByteArray_GET_SIZE(self);
int result = PyByteArray_Resize((PyObject *)self, size);
if (result < 0) {
return NULL;
}
// Set new bytes to null bytes
if (size > start_size) {
memset(PyByteArray_AS_STRING(self) + start_size, 0, size - start_size);
}
Py_RETURN_NONE;
}


/*[clinic input]
@critical_section
bytearray.translate
Expand Down
2 changes: 1 addition & 1 deletion Objects/clinic/bytearrayobject.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

You are viewing a condensed version of this merge commit. You can view the full changes here.