[New-bugs-announce] [issue46193] Using a dictionary for open files.

Keepun report at bugs.python.org
Wed Dec 29 07:34:59 EST 2021


New submission from Keepun <keepun at gmail.com>:

"""
Using a dictionary for open files.

The file is filled with NULL. Only the last entry is normal.

Result:
00 00 00 00 ... 00 0A 48 65 6C 6C 6F 0A

Ubuntu - 3.8.10
Windows - 3.9.8
"""
fhandles = {}
for f in range(100):
    fh = fhandles.setdefault("suffix", open(r"test.txt", "w"))
    fh.write("\nHello\n")
    fh.flush()
for f in fhandles.values():
    f.close()

import sys
print(sys.version_info)

----------
components: IO
messages: 409303
nosy: Keepun
priority: normal
severity: normal
status: open
title: Using a dictionary for open files.
type: behavior
versions: Python 3.8, Python 3.9

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


More information about the New-bugs-announce mailing list