Skip to content

Adding read/readline() after write appends to EOF, not to the position #117095

Open
@dom-0

Description

@dom-0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-IOtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions