summaryrefslogtreecommitdiffstats
path: root/Modules/_io/bytesio.c
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2015-02-03 20:43:23 (GMT)
committerStefan Krah <skrah@bytereef.org>2015-02-03 20:43:23 (GMT)
commit650c1e818d7bbb5d51501051fca773b3b8ea6bf3 (patch)
tree5fdc035e52a060552f90293c04f8df9537e86def /Modules/_io/bytesio.c
parent38c30e6c8e34241a1ea226fdd4ff74be6a8ee846 (diff)
downloadcpython-650c1e818d7bbb5d51501051fca773b3b8ea6bf3.zip
cpython-650c1e818d7bbb5d51501051fca773b3b8ea6bf3.tar.gz
cpython-650c1e818d7bbb5d51501051fca773b3b8ea6bf3.tar.bz2
Issue #14203: Remove obsolete support for view==NULL in bytesiobuf_getbuffer()
and array_buffer_getbuf().
Diffstat (limited to 'Modules/_io/bytesio.c')
-rw-r--r--Modules/_io/bytesio.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c
index 0a272ec..fc4ea74 100644
--- a/Modules/_io/bytesio.c
+++ b/Modules/_io/bytesio.c
@@ -1028,23 +1028,24 @@ PyTypeObject PyBytesIO_Type = {
static int
bytesiobuf_getbuffer(bytesiobuf *obj, Py_buffer *view, int flags)
{
- int ret;
bytesio *b = (bytesio *) obj->source;
+
+ if (view == NULL) {
+ PyErr_SetString(PyExc_BufferError,
+ "bytesiobuf_getbuffer: view==NULL argument is obsolete");
+ return -1;
+ }
if (SHARED_BUF(b)) {
if (unshare_buffer(b, b->string_size) < 0)
return -1;
}
- if (view == NULL) {
- b->exports++;
- return 0;
- }
- ret = PyBuffer_FillInfo(view, (PyObject*)obj,
+
+ /* cannot fail if view != NULL and readonly == 0 */
+ (void)PyBuffer_FillInfo(view, (PyObject*)obj,
PyBytes_AS_STRING(b->buf), b->string_size,
0, flags);
- if (ret >= 0) {
- b->exports++;
- }
- return ret;
+ b->exports++;
+ return 0;
}
static void