@@ -44,6 +44,10 @@ Direct API functions
4444
4545 On failure, return ``NULL `` with an exception set.
4646
47+ .. note ::
48+ If the object implements the buffer protocol, then the buffer
49+ must not be mutated while the bytearray object is being created.
50+
4751
4852.. c :function :: PyObject* PyByteArray_FromStringAndSize (const char *string, Py_ssize_t len)
4953
@@ -58,6 +62,10 @@ Direct API functions
5862
5963 On failure, return ``NULL `` with an exception set.
6064
65+ .. note ::
66+ If the object implements the buffer protocol, then the buffer
67+ must not be mutated while the bytearray object is being created.
68+
6169
6270.. c :function :: Py_ssize_t PyByteArray_Size (PyObject *bytearray)
6371
@@ -70,6 +78,9 @@ Direct API functions
7078 ``NULL `` pointer. The returned array always has an extra
7179 null byte appended.
7280
81+ .. note ::
82+ It is not thread-safe to mutate the bytearray object while using the returned char array.
83+
7384
7485.. c :function :: int PyByteArray_Resize (PyObject *bytearray, Py_ssize_t len)
7586
@@ -89,6 +100,9 @@ These macros trade safety for speed and they don't check pointers.
89100
90101 Similar to :c:func: `PyByteArray_AsString `, but without error checking.
91102
103+ .. note ::
104+ It is not thread-safe to mutate the bytearray object while using the returned char array.
105+
92106
93107.. c :function :: Py_ssize_t PyByteArray_GET_SIZE (PyObject *bytearray)
94108
0 commit comments