https://github.com/python/cpython/commit/fbba343622c9e4a38c8ef0f0b0e311164394d76a commit: fbba343622c9e4a38c8ef0f0b0e311164394d76a branch: main author: Pablo Galindo Salgado <[email protected]> committer: pablogsal <[email protected]> date: 2026-05-07T22:06:53+03:00 summary:
gh-106693: Explicitly mark ob_sval as unsigned char to avoid UB (#106826) Signed-off-by: Pablo Galindo <[email protected]> files: M Include/cpython/bytesobject.h diff --git a/Include/cpython/bytesobject.h b/Include/cpython/bytesobject.h index 85bc2b827df8fb..550b5fcb952e68 100644 --- a/Include/cpython/bytesobject.h +++ b/Include/cpython/bytesobject.h @@ -5,7 +5,7 @@ typedef struct { PyObject_VAR_HEAD Py_DEPRECATED(3.11) Py_hash_t ob_shash; - char ob_sval[1]; + unsigned char ob_sval[1]; /* Invariants: * ob_sval contains space for 'ob_size+1' elements. @@ -20,7 +20,7 @@ PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t); #define _PyBytes_CAST(op) \ (assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op)) -static inline char* PyBytes_AS_STRING(PyObject *op) +static inline unsigned char* PyBytes_AS_STRING(PyObject *op) { return _PyBytes_CAST(op)->ob_sval; } _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
