Antoine Pitrou wrote:
Brian Quinlan <brian <at> sweetapp.com> writes:
I don't see why this is helpful. Could you explain why
_RawIOBase.close() calling self.flush() is useful?
I could not explain it for sure since I didn't write the Python version.
I suppose it's so that people who only override flush() automatically get the
flush-on-close behaviour.
But the way that the code is currently written, flush only gets called
*after* the file has been closed (see my original example). It seems
very unlikely that this is the behavior that the subclass would want/expect.
So any objections to me changing IOBase (and the C implementation) to:
def close(self):
"""Flush and close the IO object.
This method has no effect if the file is already closed.
"""
if not self.__closed:
try:
- self.flush()
+ IOBase.flush(self)
except IOError:
pass # If flush() fails, just give up
self.__closed = True
Cheers,
Brian
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com