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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4