Adding read/readline() after write appends to EOF, not to the position
Open
Nobody has claimed this yet.
interpreter-core
topic-IO
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
with open("testfile", "r+") as my_file:
text = my_file.write("========")
print(my_file.readline())
Instead of writing to the beginning of the file, the program writes to the EOF even if readline() is placed after write.
CPython versions tested on:
3.8, 3.9
Operating systems tested on:
Windows
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied open("testfile", "r+") example on the reported CPython versions and Windows environment. Compare the observed read position with the documented file I/O behavior; done means determining whether this is an implementation bug or expected behavior and identifying the relevant CPython change or documentation needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100