diff options
Diffstat (limited to 'Objects')
| -rw-r--r-- | Objects/abstract.c | 7 | ||||
| -rw-r--r-- | Objects/bytearrayobject.c | 15 |
2 files changed, 13 insertions, 9 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 483f4da..06e3382 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -612,7 +612,12 @@ int PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len, int readonly, int flags) { - if (view == NULL) return 0; /* XXX why not -1? */ + if (view == NULL) { + PyErr_SetString(PyExc_BufferError, + "PyBuffer_FillInfo: view==NULL argument is obsolete"); + return -1; + } + if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) && (readonly == 1)) { PyErr_SetString(PyExc_BufferError, diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index ce22f4b..8b3267e 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -60,18 +60,17 @@ _getbytevalue(PyObject* arg, int *value) static int bytearray_getbuffer(PyByteArrayObject *obj, Py_buffer *view, int flags) { - int ret; void *ptr; if (view == NULL) { - obj->ob_exports++; - return 0; + PyErr_SetString(PyExc_BufferError, + "bytearray_getbuffer: view==NULL argument is obsolete"); + return -1; } ptr = (void *) PyByteArray_AS_STRING(obj); - ret = PyBuffer_FillInfo(view, (PyObject*)obj, ptr, Py_SIZE(obj), 0, flags); - if (ret >= 0) { - obj->ob_exports++; - } - return ret; + /* cannot fail if view != NULL and readonly == 0 */ + (void)PyBuffer_FillInfo(view, (PyObject*)obj, ptr, Py_SIZE(obj), 0, flags); + obj->ob_exports++; + return 0; } static void |
