Skip to content

Commit 5e68276

Browse files
[3.12] pythongh-107801: Document io.TextIOWrapper.tell (python#108265)
(cherry picked from commit 38afa4a)
1 parent 752d525 commit 5e68276

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

Doc/library/io.rst

+9-1
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

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/textio.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -2650,11 +2650,16 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
26502650

26512651
/*[clinic input]
26522652
_io.TextIOWrapper.tell
2653+
2654+
Return the stream position as an opaque number.
2655+
2656+
The return value of tell() can be given as input to seek(), to restore a
2657+
previous stream position.
26532658
[clinic start generated code]*/
26542659

26552660
static PyObject *
26562661
_io_TextIOWrapper_tell_impl(textio *self)
2657-
/*[clinic end generated code: output=4f168c08bf34ad5f input=9a2caf88c24f9ddf]*/
2662+
/*[clinic end generated code: output=4f168c08bf34ad5f input=0852d627d76fb520]*/
26582663
{
26592664
PyObject *res;
26602665
PyObject *posobj = NULL;

0 commit comments

Comments
 (0)