summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index daf04eb..07d4b89 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -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);