Skip to content

Commit a1af688

Browse files
fix: make bytearray.resize thread-safe
1 parent 72eca2a commit a1af688

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Objects/bytearrayobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,7 @@ bytearray_removesuffix_impl(PyByteArrayObject *self, Py_buffer *suffix)
15061506

15071507

15081508
/*[clinic input]
1509+
@critical_section
15091510
bytearray.resize
15101511
size: Py_ssize_t
15111512
New size to resize to.
@@ -1515,10 +1516,10 @@ Resize the internal buffer of bytearray to len.
15151516

15161517
static PyObject *
15171518
bytearray_resize_impl(PyByteArrayObject *self, Py_ssize_t size)
1518-
/*[clinic end generated code: output=f73524922990b2d9 input=6c9a260ca7f72071]*/
1519+
/*[clinic end generated code: output=f73524922990b2d9 input=116046316a2b5cfc]*/
15191520
{
15201521
Py_ssize_t start_size = PyByteArray_GET_SIZE(self);
1521-
int result = PyByteArray_Resize((PyObject *)self, size);
1522+
int result = bytearray_resize_lock_held((PyObject *)self, size);
15221523
if (result < 0) {
15231524
return NULL;
15241525
}

Objects/clinic/bytearrayobject.c.h

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)