diff options
Diffstat (limited to 'Lib/sunau.py')
-rw-r--r-- | Lib/sunau.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Lib/sunau.py b/Lib/sunau.py index 4f0885a..31b280d 100644 --- a/Lib/sunau.py +++ b/Lib/sunau.py @@ -406,12 +406,15 @@ 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() - 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() + finally: + self._file = None # # private methods |