diff options
Diffstat (limited to 'Lib/sunau.py')
-rw-r--r-- | Lib/sunau.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Lib/sunau.py b/Lib/sunau.py index 5212370..15f7b03 100644 --- a/Lib/sunau.py +++ b/Lib/sunau.py @@ -414,14 +414,17 @@ class Au_write: self._patchheader() def close(self): - self._ensure_header_written() - if self._nframeswritten != self._nframes or \ - self._datalength != self._datawritten: - self._patchheader() - self._file.flush() - if self._opened and self._file: - self._file.close() - self._file = None + if self._file: + try: + self._ensure_header_written() + if self._nframeswritten != self._nframes or \ + self._datalength != self._datawritten: + self._patchheader() + self._file.flush() + if self._opened and self._file: + self._file.close() + finally: + self._file = None # # private methods |