mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-114685: PyBuffer_FillInfo() now raises on PyBUF_{READ,WRITE} (GH-114802)
This commit is contained in:
parent
da8f9fb2ea
commit
929d44e15a
4 changed files with 56 additions and 5 deletions
|
@ -767,11 +767,17 @@ PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) &&
|
||||
(readonly == 1)) {
|
||||
PyErr_SetString(PyExc_BufferError,
|
||||
"Object is not writable.");
|
||||
return -1;
|
||||
if (flags != PyBUF_SIMPLE) { /* fast path */
|
||||
if (flags == PyBUF_READ || flags == PyBUF_WRITE) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) &&
|
||||
(readonly == 1)) {
|
||||
PyErr_SetString(PyExc_BufferError,
|
||||
"Object is not writable.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
view->obj = Py_XNewRef(obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue