diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-12 18:35:33 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-12 18:35:33 (GMT) |
commit | 499d82136dbe48680b9a90e7e5f4ed48eea7866a (patch) | |
tree | a2f04a321ecd80bcb4dcec709ee28b40a121e4a7 /Lib/sunau.py | |
parent | 5b68d649920dd84515950a5a02ffdac4ec15c4a8 (diff) | |
download | cpython-499d82136dbe48680b9a90e7e5f4ed48eea7866a.zip cpython-499d82136dbe48680b9a90e7e5f4ed48eea7866a.tar.gz cpython-499d82136dbe48680b9a90e7e5f4ed48eea7866a.tar.bz2 |
Issue #18919: If the close() method of a writer in the sunau or wave module
failed, second invocation of close() and destructor no more raise an
exception. Second invocation of close() on sunau writer now has no effects.
The aifc module now accepts lower case of names of the 'ulaw' and 'alaw'
codecs.
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 |