mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
Issue #16485: Fix file descriptor not being closed if file header patching fails on closing of aifc file.
This commit is contained in:
commit
f1b63c6f0e
3 changed files with 19 additions and 3 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue