diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-12 18:36:10 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-12 18:36:10 (GMT) |
commit | e23b2d06c765998d457f97356d49e6ad71fd6684 (patch) | |
tree | 0db1a671a50ff94a8d7c005f59b72aa2b8545fcf /Lib/wave.py | |
parent | 5c01d99c12876263d8cc700a11cce9ad88994096 (diff) | |
download | cpython-e23b2d06c765998d457f97356d49e6ad71fd6684.zip cpython-e23b2d06c765998d457f97356d49e6ad71fd6684.tar.gz cpython-e23b2d06c765998d457f97356d49e6ad71fd6684.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.
Diffstat (limited to 'Lib/wave.py')
-rw-r--r-- | Lib/wave.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/wave.py b/Lib/wave.py index 54f0302..2c386a5 100644 --- a/Lib/wave.py +++ b/Lib/wave.py @@ -436,11 +436,13 @@ class Wave_write: def close(self): if self._file: - self._ensure_header_written(0) - if self._datalength != self._datawritten: - self._patchheader() - self._file.flush() - self._file = None + try: + self._ensure_header_written(0) + if self._datalength != self._datawritten: + self._patchheader() + self._file.flush() + finally: + self._file = None if self._i_opened_the_file: self._i_opened_the_file.close() self._i_opened_the_file = None |