[issue46193] Using a dictionary for open files.

Eryk Sun report at bugs.python.org
Wed Dec 29 08:15:12 EST 2021


Eryk Sun <eryksun at gmail.com> added the comment:

Every time open(r"test.txt", "w") is called, the existing "test.txt" file gets overwritten in the filesystem as an empty file. For each iteration, setdefault() returns a reference to the first file object, which advances its file pointer with each fh.write("\nHello\n") call. For the last write, the file pointer is at offset 693 (i.e. 7 * 99), and the OS first writes null bytes up to the file pointer. This is normal behavior, not a bug.

----------
nosy: +eryksun

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46193>
_______________________________________


More information about the Python-bugs-list mailing list