[issue18082] Inconsistent behavior of IOBase methods on closed files
Martin Panter
report at bugs.python.org
Thu Aug 6 05:07:00 CEST 2015
Martin Panter added the comment:
The documentation <https://docs.python.org/dev/library/io.html#io.IOBase> says “. . . calling any method (even inquiries) on a closed stream is undefined. Implementations may raise ValueError”. So IMO you shouldn’t rely on any particular success or failure behaviour of these methods when a stream is closed.
Having the stream methods waste time calling out to Python methods and descriptors like readable() and “closed” all the time can make things unnecessarily slow and inefficient (see my work at the end of Issue 18003 for example). On the other hand, removing the existing checks could potentially break someone’s code. I suggest closing this, unless someone has a specific proposal or reason to change.
----------
nosy: +vadmium
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18082>
_______________________________________
More information about the Python-bugs-list
mailing list