From 2ac139e7e16d90376e21a30654715f1db6a1649a Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Thu, 20 Oct 2016 23:48:14 +0000 Subject: Issue #23214: Implement optional BufferedReader, BytesIO read1() argument --- Modules/_io/clinic/bytesio.c.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'Modules/_io/clinic/bytesio.c.h') diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h index c64ce5c77c..1434782925 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]*/ -- cgit v1.2.1 From 7372e18fa83aa35766f8f6fdf3aed27fac2d52d2 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Jan 2017 01:35:17 +0100 Subject: Run Argument Clinic: METH_VARARGS=>METH_FASTCALL Issue #29286. Run Argument Clinic to get the new faster METH_FASTCALL calling convention for functions using only positional arguments. --- Modules/_io/clinic/bytesio.c.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Modules/_io/clinic/bytesio.c.h') diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h index 1434782925..11b976c503 100644 --- a/Modules/_io/clinic/bytesio.c.h +++ b/Modules/_io/clinic/bytesio.c.h @@ -358,22 +358,26 @@ PyDoc_STRVAR(_io_BytesIO_seek__doc__, "Returns the new absolute position."); #define _IO_BYTESIO_SEEK_METHODDEF \ - {"seek", (PyCFunction)_io_BytesIO_seek, METH_VARARGS, _io_BytesIO_seek__doc__}, + {"seek", (PyCFunction)_io_BytesIO_seek, METH_FASTCALL, _io_BytesIO_seek__doc__}, static PyObject * _io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence); static PyObject * -_io_BytesIO_seek(bytesio *self, PyObject *args) +_io_BytesIO_seek(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_ssize_t pos; int whence = 0; - if (!PyArg_ParseTuple(args, "n|i:seek", + if (!_PyArg_ParseStack(args, nargs, "n|i:seek", &pos, &whence)) { goto exit; } + + if (!_PyArg_NoStackKeywords("seek", kwnames)) { + goto exit; + } return_value = _io_BytesIO_seek_impl(self, pos, whence); exit: @@ -448,4 +452,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=8f469431da1b3857 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=056f24eece495a8f input=a9049054013a1b77]*/ -- cgit v1.2.1 From 104cb4a3bacdf9764f9f8670a80da16390231337 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Jan 2017 02:21:47 +0100 Subject: Run Argument Clinic: METH_VARARGS=>METH_FASTCALL Issue #29286. Run Argument Clinic to get the new faster METH_FASTCALL calling convention for functions using "boring" positional arguments. Manually fix _elementtree: _elementtree_XMLParser_doctype() must remain consistent with the clinic code. --- Modules/_io/clinic/bytesio.c.h | 52 +++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'Modules/_io/clinic/bytesio.c.h') diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h index 11b976c503..656e7ecd13 100644 --- a/Modules/_io/clinic/bytesio.c.h +++ b/Modules/_io/clinic/bytesio.c.h @@ -158,22 +158,26 @@ PyDoc_STRVAR(_io_BytesIO_read__doc__, "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READ_METHODDEF \ - {"read", (PyCFunction)_io_BytesIO_read, METH_VARARGS, _io_BytesIO_read__doc__}, + {"read", (PyCFunction)_io_BytesIO_read, METH_FASTCALL, _io_BytesIO_read__doc__}, static PyObject * _io_BytesIO_read_impl(bytesio *self, PyObject *arg); static PyObject * -_io_BytesIO_read(bytesio *self, PyObject *args) +_io_BytesIO_read(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "read", + if (!_PyArg_UnpackStack(args, nargs, "read", 0, 1, &arg)) { goto exit; } + + if (!_PyArg_NoStackKeywords("read", kwnames)) { + goto exit; + } return_value = _io_BytesIO_read_impl(self, arg); exit: @@ -190,22 +194,26 @@ PyDoc_STRVAR(_io_BytesIO_read1__doc__, "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READ1_METHODDEF \ - {"read1", (PyCFunction)_io_BytesIO_read1, METH_VARARGS, _io_BytesIO_read1__doc__}, + {"read1", (PyCFunction)_io_BytesIO_read1, METH_FASTCALL, _io_BytesIO_read1__doc__}, static PyObject * _io_BytesIO_read1_impl(bytesio *self, PyObject *size); static PyObject * -_io_BytesIO_read1(bytesio *self, PyObject *args) +_io_BytesIO_read1(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *size = Py_None; - if (!PyArg_UnpackTuple(args, "read1", + if (!_PyArg_UnpackStack(args, nargs, "read1", 0, 1, &size)) { goto exit; } + + if (!_PyArg_NoStackKeywords("read1", kwnames)) { + goto exit; + } return_value = _io_BytesIO_read1_impl(self, size); exit: @@ -223,22 +231,26 @@ PyDoc_STRVAR(_io_BytesIO_readline__doc__, "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READLINE_METHODDEF \ - {"readline", (PyCFunction)_io_BytesIO_readline, METH_VARARGS, _io_BytesIO_readline__doc__}, + {"readline", (PyCFunction)_io_BytesIO_readline, METH_FASTCALL, _io_BytesIO_readline__doc__}, static PyObject * _io_BytesIO_readline_impl(bytesio *self, PyObject *arg); static PyObject * -_io_BytesIO_readline(bytesio *self, PyObject *args) +_io_BytesIO_readline(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "readline", + if (!_PyArg_UnpackStack(args, nargs, "readline", 0, 1, &arg)) { goto exit; } + + if (!_PyArg_NoStackKeywords("readline", kwnames)) { + goto exit; + } return_value = _io_BytesIO_readline_impl(self, arg); exit: @@ -256,22 +268,26 @@ PyDoc_STRVAR(_io_BytesIO_readlines__doc__, "total number of bytes in the lines returned."); #define _IO_BYTESIO_READLINES_METHODDEF \ - {"readlines", (PyCFunction)_io_BytesIO_readlines, METH_VARARGS, _io_BytesIO_readlines__doc__}, + {"readlines", (PyCFunction)_io_BytesIO_readlines, METH_FASTCALL, _io_BytesIO_readlines__doc__}, static PyObject * _io_BytesIO_readlines_impl(bytesio *self, PyObject *arg); static PyObject * -_io_BytesIO_readlines(bytesio *self, PyObject *args) +_io_BytesIO_readlines(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "readlines", + if (!_PyArg_UnpackStack(args, nargs, "readlines", 0, 1, &arg)) { goto exit; } + + if (!_PyArg_NoStackKeywords("readlines", kwnames)) { + goto exit; + } return_value = _io_BytesIO_readlines_impl(self, arg); exit: @@ -323,22 +339,26 @@ PyDoc_STRVAR(_io_BytesIO_truncate__doc__, "The current file position is unchanged. Returns the new size."); #define _IO_BYTESIO_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)_io_BytesIO_truncate, METH_VARARGS, _io_BytesIO_truncate__doc__}, + {"truncate", (PyCFunction)_io_BytesIO_truncate, METH_FASTCALL, _io_BytesIO_truncate__doc__}, static PyObject * _io_BytesIO_truncate_impl(bytesio *self, PyObject *arg); static PyObject * -_io_BytesIO_truncate(bytesio *self, PyObject *args) +_io_BytesIO_truncate(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "truncate", + if (!_PyArg_UnpackStack(args, nargs, "truncate", 0, 1, &arg)) { goto exit; } + + if (!_PyArg_NoStackKeywords("truncate", kwnames)) { + goto exit; + } return_value = _io_BytesIO_truncate_impl(self, arg); exit: @@ -452,4 +472,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=056f24eece495a8f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=138ee6ad6951bc84 input=a9049054013a1b77]*/ -- cgit v1.2.1