Skip to content

Commit bd951cd

Browse files
[3.11] gh-107801: Document io.TextIOWrapper.tell (#108265) (#108548)
(cherry picked from commit 38afa4a)
1 parent 73f89b1 commit bd951cd

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

Doc/library/io.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,13 +1054,21 @@ Text I/O
10541054

10551055
* ``seek(0, SEEK_SET)``: Rewind to the start of the stream.
10561056
* ``seek(cookie, SEEK_SET)``: Restore a previous position;
1057-
*cookie* **must be** a number returned by :meth:`!tell`.
1057+
*cookie* **must be** a number returned by :meth:`tell`.
10581058
* ``seek(0, SEEK_END)``: Fast-forward to the end of the stream.
10591059
* ``seek(0, SEEK_CUR)``: Leave the current stream position unchanged.
10601060

10611061
Any other argument combinations are invalid,
10621062
and may raise exceptions.
10631063

1064+
.. method:: tell()
1065+
1066+
Return the stream position as an opaque number.
1067+
The return value of :meth:`!tell` can be given as input to :meth:`seek`,
1068+
to restore a previous stream position.
1069+
1070+
1071+
10641072
.. class:: StringIO(initial_value='', newline='\n')
10651073

10661074
A text stream using an in-memory text buffer. It inherits

Modules/_io/clinic/textio.c.h

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/textio.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2627,11 +2627,16 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
26272627

26282628
/*[clinic input]
26292629
_io.TextIOWrapper.tell
2630+
2631+
Return the stream position as an opaque number.
2632+
2633+
The return value of tell() can be given as input to seek(), to restore a
2634+
previous stream position.
26302635
[clinic start generated code]*/
26312636

26322637
static PyObject *
26332638
_io_TextIOWrapper_tell_impl(textio *self)
2634-
/*[clinic end generated code: output=4f168c08bf34ad5f input=9a2caf88c24f9ddf]*/
2639+
/*[clinic end generated code: output=4f168c08bf34ad5f input=0852d627d76fb520]*/
26352640
{
26362641
PyObject *res;
26372642
PyObject *posobj = NULL;

0 commit comments

Comments
 (0)