[issue5700] io.FileIO calls flush() after file closed

Serhiy Storchaka report at bugs.python.org
Sun Oct 12 15:55:15 CEST 2014


Serhiy Storchaka added the comment:

Yet one related bug is that flush() isn't called at all if the file was opened with closefd=False.

>>> import io, os
>>> class MyIO(io.FileIO):
...     def flush(self):
...         print('closed:', self.closed)
... 
>>> fd = os.open('test.out', os.O_WRONLY|os.O_CREAT)
>>> f = MyIO(fd, 'wb', closefd=False)
>>> f.close()

The proposed simple patch fixes both bugs.

----------
assignee:  -> serhiy.storchaka
components: +IO
stage:  -> patch review
type:  -> behavior
versions: +Python 3.4, Python 3.5 -Python 3.2, Python 3.3
Added file: http://bugs.python.org/file36889/fileio_flush_closed.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5700>
_______________________________________


More information about the Python-bugs-list mailing list