This makes test_resource.py pass, and I think it's the right thing
to do: if you're closing a file after encountering an I/O error
there's nothing you can do about it. If you want the error, you
can call flush() yourself.
if not self.__closed:
try:
self.flush()
- finally:
- self.__closed = True
+ except IOError:
+ pass # If flush() fails, just give up
+ self.__closed = True
def __del__(self) -> None:
"""Destructor. Calls close()."""
def close(self):
if not self.closed:
- self.flush()
+ try:
+ self.flush()
+ except IOError:
+ pass # If flush() fails, just give up
self.raw.close()
### Inquiries ###
self._telling = self._seekable
def close(self):
- self.flush()
+ try:
+ self.flush()
+ except:
+ pass # If flush() fails, just give up
self.buffer.close()
@property