summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2015-02-03 15:57:21 (GMT)
committerStefan Krah <skrah@bytereef.org>2015-02-03 15:57:21 (GMT)
commit5178d91be09d73900699655b3ddecc0482e7942f (patch)
treef32b40a9dd880cb573ec7d7003a992d7456277e7 /Objects/bytearrayobject.c
parent72777614287a3f0feaaf1d0987ec275e94ede280 (diff)
downloadcpython-5178d91be09d73900699655b3ddecc0482e7942f.zip
cpython-5178d91be09d73900699655b3ddecc0482e7942f.tar.gz
cpython-5178d91be09d73900699655b3ddecc0482e7942f.tar.bz2
Issue #14203: Remove obsolete support for view==NULL in PyBuffer_FillInfo()
and bytearray_getbuffer(). Both functions now raise BufferError in that case.
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r--Objects/bytearrayobject.c15
1 files changed, 7 insertions, 8 deletions
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