[Python-Dev] Possible py3k io wierdness (original) (raw)

Brian Quinlan brian at sweetapp.com
Sun Apr 5 12:56:47 CEST 2009


Antoine Pitrou wrote:

Brian Quinlan <brian 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:

Cheers, Brian



More information about the Python-Dev mailing list