summaryrefslogtreecommitdiffstats
path: root/Lib/sunau.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-10 10:24:41 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-10 10:24:41 (GMT)
commit7e7a3dba5fd4262269f713dfe21ba7e4746fc2dd (patch)
treea0777a3e70ae76f294fac756c684ec4e24d5df1d /Lib/sunau.py
parent842f00e72509db50957ceb00d289b305dbc5a0a5 (diff)
downloadcpython-7e7a3dba5fd4262269f713dfe21ba7e4746fc2dd.zip
cpython-7e7a3dba5fd4262269f713dfe21ba7e4746fc2dd.tar.gz
cpython-7e7a3dba5fd4262269f713dfe21ba7e4746fc2dd.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/sunau.py')
-rw-r--r--Lib/sunau.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/sunau.py b/Lib/sunau.py
index 3da41b7..e760093 100644
--- a/Lib/sunau.py
+++ b/Lib/sunau.py
@@ -295,9 +295,11 @@ class Au_read:
self._soundpos = pos
def close(self):
- if self._opened and self._file:
- self._file.close()
- self._file = None
+ file = self._file
+ if file:
+ self._file = None
+ if self._opened:
+ file.close()
class Au_write:
@@ -438,9 +440,10 @@ class Au_write:
self._patchheader()
self._file.flush()
finally:
- if self._opened and self._file:
- self._file.close()
+ file = self._file
self._file = None
+ if self._opened:
+ file.close()
#
# private methods