Currently, in the CPython C code, multiple functions treat bytes objects as mutable. For example, they use char* to access their data, instead of const char*.
In the worst case, it can lead to bad bugs like issue gh-155702 in sqlite3 which modifies an immutable bytes object.
Some functions can be rewritten using PyBytesWriter C API to avoid that.
Linked PRs
Currently, in the CPython C code, multiple functions treat
bytesobjects as mutable. For example, they usechar*to access their data, instead ofconst char*.In the worst case, it can lead to bad bugs like issue gh-155702 in sqlite3 which modifies an immutable bytes object.
Some functions can be rewritten using
PyBytesWriterC API to avoid that.Linked PRs
const char*#155751