]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-107801: Document io.TextIOWrapper.tell (#108265)
authorErlend E. Aasland <erlend@python.org>
Sun, 27 Aug 2023 20:35:27 +0000 (22:35 +0200)
committerGitHub <noreply@github.com>
Sun, 27 Aug 2023 20:35:27 +0000 (20:35 +0000)
Doc/library/io.rst
Modules/_io/clinic/textio.c.h
Modules/_io/textio.c

index 792bf43d9811bbe0c0d90809faddd79286401342..25f4d0d584133355be247d363d58b3f35c7457e2 100644 (file)
@@ -1054,13 +1054,21 @@ Text I/O
 
       * ``seek(0, SEEK_SET)``: Rewind to the start of the stream.
       * ``seek(cookie, SEEK_SET)``: Restore a previous position;
-        *cookie* **must be** a number returned by :meth:`!tell`.
+        *cookie* **must be** a number returned by :meth:`tell`.
       * ``seek(0, SEEK_END)``: Fast-forward to the end of the stream.
       * ``seek(0, SEEK_CUR)``: Leave the current stream position unchanged.
 
       Any other argument combinations are invalid,
       and may raise exceptions.
 
+   .. method:: tell()
+
+      Return the stream position as an opaque number.
+      The return value of :meth:`!tell` can be given as input to :meth:`seek`,
+      to restore a previous stream position.
+
+
+
 .. class:: StringIO(initial_value='', newline='\n')
 
    A text stream using an in-memory text buffer.  It inherits
index 03d5facedfb513dafae0336c5e049650d22f5223..ce6efbe20b6bba3b3e4c0d96eb6442343cf3608d 100644 (file)
@@ -813,7 +813,11 @@ exit:
 PyDoc_STRVAR(_io_TextIOWrapper_tell__doc__,
 "tell($self, /)\n"
 "--\n"
-"\n");
+"\n"
+"Return the stream position as an opaque number.\n"
+"\n"
+"The return value of tell() can be given as input to seek(), to restore a\n"
+"previous stream position.");
 
 #define _IO_TEXTIOWRAPPER_TELL_METHODDEF    \
     {"tell", (PyCFunction)_io_TextIOWrapper_tell, METH_NOARGS, _io_TextIOWrapper_tell__doc__},
@@ -976,4 +980,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
 {
     return _io_TextIOWrapper_close_impl(self);
 }
-/*[clinic end generated code: output=c3a8eb2591be1bf7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=390af0e65a0d02c0 input=a9049054013a1b77]*/
index d87bd0054d44381e346655eb2d016d9830b78714..8e44d453269a71e0678f9bc1043ee3422b59460f 100644 (file)
@@ -2640,11 +2640,16 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
 
 /*[clinic input]
 _io.TextIOWrapper.tell
+
+Return the stream position as an opaque number.
+
+The return value of tell() can be given as input to seek(), to restore a
+previous stream position.
 [clinic start generated code]*/
 
 static PyObject *
 _io_TextIOWrapper_tell_impl(textio *self)
-/*[clinic end generated code: output=4f168c08bf34ad5f input=9a2caf88c24f9ddf]*/
+/*[clinic end generated code: output=4f168c08bf34ad5f input=0852d627d76fb520]*/
 {
     PyObject *res;
     PyObject *posobj = NULL;