Hey, I noticed that the call pattern of the C-implemented io libraries is as follows (translating from C to Python):
class _FileIO(object): def flush(self): if self.__IOBase_closed: raise ... def close(self): self.flush() self.__IOBase_closed = True class _RawIOBase(_FileIO): def close(self): # do close _FileIO.close(self) This means that, if a subclass overrides flush(), it will be called after the file has been closed e.g. >>> import io >>> class MyIO(io.FileIO): ... def flush(self): ... print('closed:', self.closed) ... >>> f = MyIO('test.out', 'wb') >>> f.close() closed: True It seems to me that, during close, calls should only propagate up the class hierarchy i.e. class _FileIO(object): def flush(self): if self.__IOBase_closed: raise ... def close(self): _FileIO.flush(self) self.__IOBase_closed = True I volunteer to change this if there is agreement that this is the way to go. 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