diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-10 10:24:10 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-10 10:24:10 (GMT) |
commit | 1aa2c0f073bdbed4fa824591d53e20bbf3d01add (patch) | |
tree | 30091bc4164edcf2d192126e5db59392a3078793 /Lib/aifc.py | |
parent | c26afcc8fce54b8c920c21e2faf1259a92f4aa1f (diff) | |
download | cpython-1aa2c0f073bdbed4fa824591d53e20bbf3d01add.zip cpython-1aa2c0f073bdbed4fa824591d53e20bbf3d01add.tar.gz cpython-1aa2c0f073bdbed4fa824591d53e20bbf3d01add.tar.bz2 |
Issue #23865: close() methods in multiple modules now are idempotent and more
robust at shutdown. If needs to release multiple resources, they are released
even if errors are occured.
Diffstat (limited to 'Lib/aifc.py')
-rw-r--r-- | Lib/aifc.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py index 9ac710f..c9a021e 100644 --- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -357,10 +357,13 @@ class Aifc_read: self._soundpos = 0 def close(self): - if self._decomp: - self._decomp.CloseDecompressor() - self._decomp = None - self._file.close() + decomp = self._decomp + try: + if decomp: + self._decomp = None + decomp.CloseDecompressor() + finally: + self._file.close() def tell(self): return self._soundpos |