]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Also commit the patch ;)
authorGeorg Brandl <georg@python.org>
Thu, 15 Mar 2007 07:43:22 +0000 (07:43 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 15 Mar 2007 07:43:22 +0000 (07:43 +0000)
Lib/wave.py

index 08c51ba90c163cb1237ae51b9babca2f539337ff..b993b400c2ca5d6e0221d754b1d2d3c110458672 100644 (file)
@@ -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