gh-129107: make bytearray thread safe (#129108)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
Tomasz Pytel 2025-02-15 02:19:42 -05:00 committed by GitHub
parent d2e60d8e59
commit a05433f24a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 904 additions and 100 deletions

View file

@ -29,6 +29,10 @@ static inline char* PyByteArray_AS_STRING(PyObject *op)
static inline Py_ssize_t PyByteArray_GET_SIZE(PyObject *op) {
PyByteArrayObject *self = _PyByteArray_CAST(op);
#ifdef Py_GIL_DISABLED
return _Py_atomic_load_ssize_relaxed(&(_PyVarObject_CAST(self)->ob_size));
#else
return Py_SIZE(self);
#endif
}
#define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self))