summaryrefslogtreecommitdiffstats
path: root/Modules/_io/clinic
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-10-20 23:48:14 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-10-20 23:48:14 (GMT)
commitccb2c0e31056de091abdd62fc07ca6e4bb052f24 (patch)
tree84ff95e0152d152124b078a9f6e85f053b7147c1 /Modules/_io/clinic
parentea8762cae64813788633b7d2a93c2c513c01fdea (diff)
downloadcpython-ccb2c0e31056de091abdd62fc07ca6e4bb052f24.zip
cpython-ccb2c0e31056de091abdd62fc07ca6e4bb052f24.tar.gz
cpython-ccb2c0e31056de091abdd62fc07ca6e4bb052f24.tar.bz2
Issue #23214: Implement optional BufferedReader, BytesIO read1() argument
Diffstat (limited to 'Modules/_io/clinic')
-rw-r--r--Modules/_io/clinic/bufferedio.c.h13
-rw-r--r--Modules/_io/clinic/bytesio.c.h26
2 files changed, 30 insertions, 9 deletions
diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h
index 58144a4..dc69c48 100644
--- a/Modules/_io/clinic/bufferedio.c.h
+++ b/Modules/_io/clinic/bufferedio.c.h
@@ -140,23 +140,24 @@ exit:
}
PyDoc_STRVAR(_io__Buffered_read1__doc__,
-"read1($self, size, /)\n"
+"read1($self, size=-1, /)\n"
"--\n"
"\n");
#define _IO__BUFFERED_READ1_METHODDEF \
- {"read1", (PyCFunction)_io__Buffered_read1, METH_O, _io__Buffered_read1__doc__},
+ {"read1", (PyCFunction)_io__Buffered_read1, METH_VARARGS, _io__Buffered_read1__doc__},
static PyObject *
_io__Buffered_read1_impl(buffered *self, Py_ssize_t n);
static PyObject *
-_io__Buffered_read1(buffered *self, PyObject *arg)
+_io__Buffered_read1(buffered *self, PyObject *args)
{
PyObject *return_value = NULL;
- Py_ssize_t n;
+ Py_ssize_t n = -1;
- if (!PyArg_Parse(arg, "n:read1", &n)) {
+ if (!PyArg_ParseTuple(args, "|n:read1",
+ &n)) {
goto exit;
}
return_value = _io__Buffered_read1_impl(self, n);
@@ -475,4 +476,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=a956f394ecde4cf9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=490c97bfcfd92c51 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h
index c64ce5c..1434782 100644
--- a/Modules/_io/clinic/bytesio.c.h
+++ b/Modules/_io/clinic/bytesio.c.h
@@ -181,7 +181,7 @@ exit:
}
PyDoc_STRVAR(_io_BytesIO_read1__doc__,
-"read1($self, size, /)\n"
+"read1($self, size=-1, /)\n"
"--\n"
"\n"
"Read at most size bytes, returned as a bytes object.\n"
@@ -190,7 +190,27 @@ PyDoc_STRVAR(_io_BytesIO_read1__doc__,
"Return an empty bytes object at EOF.");
#define _IO_BYTESIO_READ1_METHODDEF \
- {"read1", (PyCFunction)_io_BytesIO_read1, METH_O, _io_BytesIO_read1__doc__},
+ {"read1", (PyCFunction)_io_BytesIO_read1, METH_VARARGS, _io_BytesIO_read1__doc__},
+
+static PyObject *
+_io_BytesIO_read1_impl(bytesio *self, PyObject *size);
+
+static PyObject *
+_io_BytesIO_read1(bytesio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *size = Py_None;
+
+ if (!PyArg_UnpackTuple(args, "read1",
+ 0, 1,
+ &size)) {
+ goto exit;
+ }
+ return_value = _io_BytesIO_read1_impl(self, size);
+
+exit:
+ return return_value;
+}
PyDoc_STRVAR(_io_BytesIO_readline__doc__,
"readline($self, size=None, /)\n"
@@ -428,4 +448,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=6382e8eb578eea64 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8f469431da1b3857 input=a9049054013a1b77]*/