mirror of
https://github.com/python/cpython.git
synced 2025-08-20 00:32:12 +00:00
Also commit the patch ;)
This commit is contained in:
parent
385cd40a67
commit
7cd6ef0913
1 changed files with 12 additions and 2 deletions
10
Lib/wave.py
10
Lib/wave.py
|
@ -159,7 +159,12 @@ class Wave_read:
|
||||||
f = __builtin__.open(f, 'rb')
|
f = __builtin__.open(f, 'rb')
|
||||||
self._i_opened_the_file = f
|
self._i_opened_the_file = f
|
||||||
# else, assume it is an open file object already
|
# else, assume it is an open file object already
|
||||||
|
try:
|
||||||
self.initfp(f)
|
self.initfp(f)
|
||||||
|
except:
|
||||||
|
if self._i_opened_the_file:
|
||||||
|
f.close()
|
||||||
|
raise
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -297,7 +302,12 @@ class Wave_write:
|
||||||
if isinstance(f, basestring):
|
if isinstance(f, basestring):
|
||||||
f = __builtin__.open(f, 'wb')
|
f = __builtin__.open(f, 'wb')
|
||||||
self._i_opened_the_file = f
|
self._i_opened_the_file = f
|
||||||
|
try:
|
||||||
self.initfp(f)
|
self.initfp(f)
|
||||||
|
except:
|
||||||
|
if self._i_opened_the_file:
|
||||||
|
f.close()
|
||||||
|
raise
|
||||||
|
|
||||||
def initfp(self, file):
|
def initfp(self, file):
|
||||||
self._file = file
|
self._file = file
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue