raise Error, 'fmt chunk and/or data chunk missing'
def __init__(self, f):
+ self._i_opened_the_file = None
if type(f) == type(''):
f = __builtin__.open(f, 'rb')
+ self._i_opened_the_file = f
# else, assume it is an open file object already
self.initfp(f)
+ def __del__(self):
+ self.close()
#
# User visible methods.
#
self._soundpos = 0
def close(self):
+ if self._i_opened_the_file:
+ self._i_opened_the_file.close()
+ self._i_opened_the_file = None
self._file = None
def tell(self):
"""
def __init__(self, f):
+ self._i_opened_the_file = None
if type(f) == type(''):
f = __builtin__.open(f, 'wb')
+ self._i_opened_the_file = f
self.initfp(f)
def initfp(self, file):
self._datalength = 0
def __del__(self):
- if self._file:
- self.close()
+ self.close()
#
# User visible methods.
self._patchheader()
def close(self):
- self._ensure_header_written(0)
- if self._datalength != self._datawritten:
- self._patchheader()
- self._file.flush()
- self._file = None
+ if self._file:
+ self._ensure_header_written(0)
+ if self._datalength != self._datawritten:
+ self._patchheader()
+ self._file.flush()
+ self._file = None
+ if self._i_opened_the_file:
+ self._i_opened_the_file.close()
+ self._i_opened_the_file = None
#
# Internal methods.