[Python-checkins] CVS: python/dist/src/Lib wave.py,1.12,1.13
Tim Peters
python-dev@python.org
Mon, 9 Oct 2000 16:43:58 -0700
- Previous message: [Python-checkins] CVS: python/dist/src/Lib/dos-8x3 test_cfg.py,NONE,1.1 test_imp.py,NONE,1.1 test_wav.py,NONE,1.1 configpa.py,1.9,1.10 mimetool.py,1.7,1.8 posixpat.py,1.12,1.13 sre_comp.py,1.6,1.7 sre_cons.py,1.4,1.5 sre_pars.py,1.7,1.8 stringio.py,1.5,1.6 test_cla.py,1.1,1.2 test_lin.py,1.2,1.3 test_min.py,1.2,1.3 test_str.py,1.11,1.12 test_uni.py,1.3,1.4 test_url.py,1.2,1.3 test_win.py,1.4,1.5 userlist.py,1.9,1.10 webbrows.py,1.3,1.4
- Next message: [Python-checkins] CVS: python/dist/src LICENSE,1.6,1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv16460/python/dist/src/lib
Modified Files:
wave.py
Log Message:
When the classes in wave.py opened files themselves, their .close() methods
didn't bother to close the files. This caused the new test_wave test to fail
under Windows, as Windows won't let you delete a file that's open. Fixed
that by ensuring the wave read & write classes' .close() and __del__ methods
close files that were opened by their constructors.
Index: wave.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/wave.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** wave.py 2000/10/09 20:01:53 1.12
--- wave.py 2000/10/09 23:43:55 1.13
***************
*** 153,161 ****
--- 153,165 ----
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.
***************
*** 169,172 ****
--- 173,179 ----
def close(self):
+ if self._i_opened_the_file:
+ self._i_opened_the_file.close()
+ self._i_opened_the_file = None
self._file = None
***************
*** 285,290 ****
--- 292,299 ----
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)
***************
*** 301,306 ****
def __del__(self):
! if self._file:
! self.close()
#
--- 310,314 ----
def __del__(self):
! self.close()
#
***************
*** 414,422 ****
def close(self):
! self._ensure_header_written(0)
! if self._datalength != self._datawritten:
! self._patchheader()
! self._file.flush()
! self._file = None
#
--- 422,434 ----
def close(self):
! 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
#
- Previous message: [Python-checkins] CVS: python/dist/src/Lib/dos-8x3 test_cfg.py,NONE,1.1 test_imp.py,NONE,1.1 test_wav.py,NONE,1.1 configpa.py,1.9,1.10 mimetool.py,1.7,1.8 posixpat.py,1.12,1.13 sre_comp.py,1.6,1.7 sre_cons.py,1.4,1.5 sre_pars.py,1.7,1.8 stringio.py,1.5,1.6 test_cla.py,1.1,1.2 test_lin.py,1.2,1.3 test_min.py,1.2,1.3 test_str.py,1.11,1.12 test_uni.py,1.3,1.4 test_url.py,1.2,1.3 test_win.py,1.4,1.5 userlist.py,1.9,1.10 webbrows.py,1.3,1.4
- Next message: [Python-checkins] CVS: python/dist/src LICENSE,1.6,1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]