Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.11] gh-107801: Document io.TextIOWrapper.tell (#108265) #108548

Merged
merged 1 commit into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Doc/library/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Modules/_io/clinic/textio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Modules/_io/textio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2627,11 +2627,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;
Expand Down
Loading