diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h --- a/Modules/_io/clinic/iobase.c.h +++ b/Modules/_io/clinic/iobase.c.h @@ -2,6 +2,45 @@ preserve [clinic start generated code]*/ +PyDoc_STRVAR(_io__IOBase_seek__doc__, +"seek($self, /, offset, whence=0)\n" +"--\n" +"\n" +"Change stream position.\n" +"\n" +"Change the stream position to the given byte offset. The offset is\n" +"interpreted relative to the position indicated by whence. Values\n" +"for whence are:\n" +"\n" +"* 0 -- start of stream (the default); offset should be zero or positive\n" +"* 1 -- current stream position; offset may be negative\n" +"* 2 -- end of stream; offset is usually negative\n" +"\n" +"Return the new absolute position."); + +#define _IO__IOBASE_SEEK_METHODDEF \ + {"seek", (PyCFunction)_io__IOBase_seek, METH_VARARGS|METH_KEYWORDS, _io__IOBase_seek__doc__}, + +static PyObject * +_io__IOBase_seek_impl(PyObject *self, PyObject *offset, int whence); + +static PyObject * +_io__IOBase_seek(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"offset", "whence", NULL}; + PyObject *offset; + int whence = 0; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:seek", _keywords, + &offset, &whence)) + goto exit; + return_value = _io__IOBase_seek_impl(self, offset, whence); + +exit: + return return_value; +} + PyDoc_STRVAR(_io__IOBase_tell__doc__, "tell($self, /)\n" "--\n" @@ -276,4 +315,4 @@ { return _io__RawIOBase_readall_impl(self); } -/*[clinic end generated code: output=fe034152b6884e65 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2102594286c3244f input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h --- a/Modules/_io/clinic/textio.c.h +++ b/Modules/_io/clinic/textio.c.h @@ -265,24 +265,25 @@ } PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__, -"seek($self, cookie, whence=0, /)\n" +"seek($self, /, offset, whence=0)\n" "--\n" "\n"); #define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \ - {"seek", (PyCFunction)_io_TextIOWrapper_seek, METH_VARARGS, _io_TextIOWrapper_seek__doc__}, + {"seek", (PyCFunction)_io_TextIOWrapper_seek, METH_VARARGS|METH_KEYWORDS, _io_TextIOWrapper_seek__doc__}, static PyObject * _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence); static PyObject * -_io_TextIOWrapper_seek(textio *self, PyObject *args) +_io_TextIOWrapper_seek(textio *self, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; + static char *_keywords[] = {"offset", "whence", NULL}; PyObject *cookieObj; int whence = 0; - if (!PyArg_ParseTuple(args, "O|i:seek", + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:seek", _keywords, &cookieObj, &whence)) goto exit; return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence); @@ -453,4 +454,4 @@ { return _io_TextIOWrapper_close_impl(self); } -/*[clinic end generated code: output=690608f85aab8ba5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7f6eef70bbd7b088 input=a9049054013a1b77]*/ diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -91,21 +91,28 @@ /* Positionning */ -PyDoc_STRVAR(iobase_seek_doc, - "Change stream position.\n" - "\n" - "Change the stream position to the given byte offset. The offset is\n" - "interpreted relative to the position indicated by whence. Values\n" - "for whence are:\n" - "\n" - "* 0 -- start of stream (the default); offset should be zero or positive\n" - "* 1 -- current stream position; offset may be negative\n" - "* 2 -- end of stream; offset is usually negative\n" - "\n" - "Return the new absolute position."); +/*[clinic input] +_io._IOBase.seek + + offset: object + whence: int = 0 + +Change stream position. + +Change the stream position to the given byte offset. The offset is +interpreted relative to the position indicated by whence. Values +for whence are: + +* 0 -- start of stream (the default); offset should be zero or positive +* 1 -- current stream position; offset may be negative +* 2 -- end of stream; offset is usually negative + +Return the new absolute position. +[clinic start generated code]*/ static PyObject * -iobase_seek(PyObject *self, PyObject *args) +_io__IOBase_seek_impl(PyObject *self, PyObject *offset, int whence) +/*[clinic end generated code: output=2f8010d73d69d237 input=8807cb26c5e9e48b]*/ { return iobase_unsupported("seek"); } @@ -743,7 +750,7 @@ #include "clinic/iobase.c.h" static PyMethodDef iobase_methods[] = { - {"seek", iobase_seek, METH_VARARGS, iobase_seek_doc}, + _IO__IOBASE_SEEK_METHODDEF _IO__IOBASE_TELL_METHODDEF {"truncate", iobase_truncate, METH_VARARGS, iobase_truncate_doc}, _IO__IOBASE_FLUSH_METHODDEF diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -2060,14 +2060,14 @@ /*[clinic input] _io.TextIOWrapper.seek - cookie as cookieObj: object + offset as cookieObj: object whence: int = 0 - / + [clinic start generated code]*/ static PyObject * _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) -/*[clinic end generated code: output=0a15679764e2d04d input=0458abeb3d7842be]*/ +/*[clinic end generated code: output=0a15679764e2d04d input=6a2868a9746bb114]*/ { PyObject *posobj; cookie_type cookie;