Crash report
Code says that it cannot fail:
|
static int |
|
bytearray_getbuffer(PyObject *self, Py_buffer *view, int flags) |
|
{ |
|
PyByteArrayObject *obj = _PyByteArray_CAST(self); |
|
if (view == NULL) { |
|
PyErr_SetString(PyExc_BufferError, |
|
"bytearray_getbuffer: view==NULL argument is obsolete"); |
|
return -1; |
|
} |
|
|
|
void *ptr = (void *) PyByteArray_AS_STRING(obj); |
|
/* cannot fail if view != NULL and readonly == 0 */ |
|
(void)PyBuffer_FillInfo(view, (PyObject*)obj, ptr, Py_SIZE(obj), 0, flags); |
But, it can:
|
if (flags != PyBUF_SIMPLE) { /* fast path */ |
|
if (flags == PyBUF_READ || flags == PyBUF_WRITE) { |
|
PyErr_BadInternalCall(); |
|
return -1; |
|
} |
I have a PR ready.
CC @JelleZijlstra
Linked PRs
Crash report
Code says that it cannot fail:
cpython/Objects/bytearrayobject.c
Lines 44 to 56 in 4cd1076
But, it can:
cpython/Objects/abstract.c
Lines 770 to 774 in 4cd1076
I have a PR ready.
CC @JelleZijlstra
Linked PRs
bytearray.__buffer__crash onPyBUF_{READ,WRITE}#126981bytearray.__buffer__crash onPyBUF_{READ,WRITE}(GH-126981) #127023