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
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