From: Georg Brandl Date: Thu, 15 Mar 2007 07:43:22 +0000 (+0000) Subject: Also commit the patch ;) X-Git-Tag: v2.5.1c1~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7cd6ef09135f69675b54e0a8532f0063912e99ed;p=thirdparty%2FPython%2Fcpython.git Also commit the patch ;) --- diff --git a/Lib/wave.py b/Lib/wave.py index 08c51ba90c16..b993b400c2ca 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