-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Docs and docstrings for io.*.seek are inconsistent #107801
Comments
Note: If anything is changed here, the relevant doc should also be changed. |
@MatthiasWiesmann would you have time to write a PR with suggestied revisions of the help text? To note, Python 3.12 will include the constants in
cc @erlend-aasland as the author of #104418 if you have any thoughts. A |
- Name positional parameters consistently: seek(offset, whence, /) - Add param docstrings to _io._IOBase.seek, so the various implementations interit them. - Use io.SEEK_*, not os.SEEK_* - Override docstrings for subclasses where 'offset' must be zero for SEEK_CUR and SEEK_END.
I agree that it is confusing that the parameter names for the low-level API Suggested improvements:
|
Neither forward seeking nor backward seeking are supported. The only supported are rewinding to the start and restoring the previous position saved by |
As a data point: on macOS, Linux, and FreeBSD, the |
Because they only work with binary files. They do not work with TextIOWrapper which support multibyte stateful codecs. |
There are a lot of tasks here. Suggesting to proceed in this order:
|
Yes, that is fine; |
3.11
3.12
3.13
|
Even in C,
|
Are you responding to a particular suggested change of #107801 (comment)? Are you suggesting another change? I'm not sure how to interpret your post. |
No, it was response to #107801 (comment). As for your proposition, it all looks reasonable. The main entries are 6 and 5. Perhaps there should be only two separate docstrings: for binary and text streams, all other classes perhaps can inherit them from parent. The module documentation can be more verbose and provide more specific details. Other entries can go to other issues. |
Thanks for clarifying.
That sounds reasonable. And of course, the TextIOWrapper docstring is a special case. |
Clearly document the supported seek() operations: - Rewind to the start of the stream - Restore a previous strema position (given by tell()) - Fast-forward to the end of the stream
- name the last parameter *whence*, like it is for seek() methods on file objects - add param docstrings - structure the valid *whence* values as a list
… docs (python#107933) (cherry picked from commit 7f87ebb) Clearly document the supported seek() operations: - Rewind to the start of the stream - Restore a previous stream position (given by tell()) - Fast-forward to the end of the stream
… docs (python#107933) (cherry picked from commit 7f87ebb) Clearly document the supported seek() operations: - Rewind to the start of the stream - Restore a previous stream position (given by tell()) - Fast-forward to the end of the stream
- Add param docstrings - Link to os.SEEK_* constants - Mention the return value in the initial paragraph
(cherry picked from commit 38afa4a)
(cherry picked from commit 38afa4a)
- Add param docstrings - Link to os.SEEK_* constants - Mention the return value in the initial paragraph Co-authored-by: Adam Turner <[email protected]>
…ython#108268) (cherry picked from commit 8178a88) - Add param docstrings - Link to os.SEEK_* constants - Mention the return value in the initial paragraph Co-authored-by: Adam Turner <[email protected]>
…ython#108268) (cherry picked from commit 8178a88) - Add param docstrings - Link to os.SEEK_* constants - Mention the return value in the initial paragraph Co-authored-by: Adam Turner <[email protected]>
… (#108656) (cherry picked from commit 8178a88) - Add param docstrings - Link to os.SEEK_* constants - Mention the return value in the initial paragraph Co-authored-by: Adam Turner <[email protected]>
… (#108655) (cherry picked from commit 8178a88) - Add param docstrings - Link to os.SEEK_* constants - Mention the return value in the initial paragraph Co-authored-by: Adam Turner <[email protected]>
* main: pythongh-108520: Fix bad fork detection in nested multiprocessing use case (python#108568) pythongh-108590: Revert pythongh-108657 (commit 400a1ce) (python#108686) pythongh-108494: Argument Clinic: Document how to generate code that uses the limited C API (python#108584) Document Python build requirements (python#108646) pythongh-101100: Fix Sphinx warnings in the Logging Cookbook (python#108678) Fix typo in multiprocessing docs (python#108666) pythongh-108669: unittest: Fix documentation for TestResult.collectedDurations (python#108670) pythongh-108590: Fix sqlite3.iterdump for invalid Unicode in TEXT columns (python#108657) Revert "pythongh-103224: Use the realpath of the Python executable in `test_venv` (pythonGH-103243)" (pythonGH-108667) pythongh-106320: Remove private _Py_ForgetReference() (python#108664) Mention Ellipsis pickling in the docs (python#103660) Revert "Use non alternate name for Kyiv (pythonGH-108533)" (pythonGH-108649) pythongh-108278: Deprecate passing the first param of sqlite3.Connection callback APIs by keyword (python#108632) pythongh-108455: peg_generator: install two stubs packages before running mypy (python#108637) pythongh-107801: Improve the accuracy of io.IOBase.seek docs (python#108268)
Lots of merged PRs here. 🚀 Anything still to do, or can the issue be closed? |
Documentation
The documentation on text handles is misleading, in particular for the
seek
method.Steps to reproduce
This produces the following documentation:
Issues
os
module, likeos.SEEK_END
are not mentioned.Generally, the behaviour is very inconsistent, seek relative to the end fail, seek relative to the start works, but might yield a situation when
read
fails.Full investigation of the issue
Linked PRs
The text was updated successfully, but these errors were encountered: