diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2012-12-29 20:36:23 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2012-12-29 20:36:23 (GMT) |
commit | f1b63c6f0ef4074ea12bdbc535c8bc9738c9a78e (patch) | |
tree | cdec2e3f4296a649f50d612b0c316fdda75b002b /Lib/aifc.py | |
parent | f2b9cf4e612551eec954ee42e4ae3f0dfde3fd03 (diff) | |
parent | 051722d554c7cab6ae93509f4939a03169d03ac1 (diff) | |
download | cpython-f1b63c6f0ef4074ea12bdbc535c8bc9738c9a78e.zip cpython-f1b63c6f0ef4074ea12bdbc535c8bc9738c9a78e.tar.gz cpython-f1b63c6f0ef4074ea12bdbc535c8bc9738c9a78e.tar.bz2 |
Issue #16485: Fix file descriptor not being closed if file header patching fails on closing of aifc file.
Diffstat (limited to 'Lib/aifc.py')
-rw-r--r-- | Lib/aifc.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py index ec4f822..a19b38f 100644 --- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -692,7 +692,9 @@ class Aifc_write: self._patchheader() def close(self): - if self._file: + if self._file is None: + return + try: self._ensure_header_written(0) if self._datawritten & 1: # quick pad to even size @@ -703,10 +705,12 @@ class Aifc_write: self._datalength != self._datawritten or \ self._marklength: self._patchheader() + finally: # Prevent ref cycles self._convert = None - self._file.close() + f = self._file self._file = None + f.close() # # Internal methods. |