diff --git a/Doc/library/io.rst b/Doc/library/io.rst index 748c49968f505c1..b0585c35705530b 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -405,7 +405,9 @@ I/O Base Classes .. method:: seek(offset, whence=os.SEEK_SET, /) - Change the stream position to the given byte *offset*, + Change the stream position to the given *offset*, + treated as a byte offset for binary streams + and a character offset for text streams, interpreted relative to the position indicated by *whence*, and return the new absolute position. Values for *whence* are: diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h index a35cac7dc0b8d7e..9f6ca457e581253 100644 --- a/Modules/_io/clinic/iobase.c.h +++ b/Modules/_io/clinic/iobase.c.h @@ -12,13 +12,16 @@ PyDoc_STRVAR(_io__IOBase_seek__doc__, "seek($self, offset, whence=os.SEEK_SET, /)\n" "--\n" "\n" -"Change the stream position to the given byte offset.\n" +"Change the stream position to the given offset.\n" "\n" " offset\n" " The stream position, relative to \'whence\'.\n" " whence\n" " The relative position to seek from.\n" "\n" +"The offset is treated as a byte offset for binary streams, and as a\n" +"character offset for text streams.\n" +"\n" "The offset is interpreted relative to the position indicated by whence.\n" "Values for whence are:\n" "\n" @@ -441,4 +444,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored)) { return _io__RawIOBase_readall_impl(self); } -/*[clinic end generated code: output=dab5e9323d191e32 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=08641f02df89a459 input=a9049054013a1b77]*/ diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index 184e0b7d1aa7f1a..3031817a8dc396e 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -97,7 +97,10 @@ _io._IOBase.seek The relative position to seek from. / -Change the stream position to the given byte offset. +Change the stream position to the given offset. + +The offset is treated as a byte offset for binary streams, and as a +character offset for text streams. The offset is interpreted relative to the position indicated by whence. Values for whence are: @@ -112,7 +115,7 @@ Return the new absolute position. static PyObject * _io__IOBase_seek_impl(PyObject *self, PyTypeObject *cls, int Py_UNUSED(offset), int Py_UNUSED(whence)) -/*[clinic end generated code: output=8bd74ea6538ded53 input=74211232b363363e]*/ +/*[clinic end generated code: output=8bd74ea6538ded53 input=2e7053a15733b5d6]*/ { _PyIO_State *state = get_io_state_by_cls(cls); return iobase_unsupported(state, "seek");