diff options
author | Georg Brandl <georg@python.org> | 2007-03-15 07:43:22 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-03-15 07:43:22 (GMT) |
commit | 7cd6ef09135f69675b54e0a8532f0063912e99ed (patch) | |
tree | ec8a61835eca6d9752fb310cc17e4fd914154be7 | |
parent | 385cd40a67e83ebe5dc6afeea24f2716548f4e9c (diff) | |
download | cpython-7cd6ef09135f69675b54e0a8532f0063912e99ed.zip cpython-7cd6ef09135f69675b54e0a8532f0063912e99ed.tar.gz cpython-7cd6ef09135f69675b54e0a8532f0063912e99ed.tar.bz2 |
Also commit the patch ;)
-rw-r--r-- | Lib/wave.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/wave.py b/Lib/wave.py index 08c51ba..b993b40 100644 --- a/Lib/wave.py +++ b/Lib/wave.py @@ -159,7 +159,12 @@ class Wave_read: f = __builtin__.open(f, 'rb') self._i_opened_the_file = f # else, assume it is an open file object already - self.initfp(f) + try: + self.initfp(f) + except: + if self._i_opened_the_file: + f.close() + raise def __del__(self): self.close() @@ -297,7 +302,12 @@ class Wave_write: if isinstance(f, basestring): f = __builtin__.open(f, 'wb') self._i_opened_the_file = f - self.initfp(f) + try: + self.initfp(f) + except: + if self._i_opened_the_file: + f.close() + raise def initfp(self, file): self._file = file |