[Python-checkins] CVS: python/dist/src/Lib zipfile.py,1.18,1.19
Tim Peters
tim_one@users.sourceforge.net
2001年11月28日 15:16:43 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv25761/python/Lib
Modified Files:
zipfile.py
Log Message:
SF bug 486480: zipfile __del__ is broken
ZipFile.__del__(): call ZipFile.close(), like its docstring says it does.
ZipFile.close(): allow calling more than once (as all file-like objects
in Python should support).
Index: zipfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** zipfile.py 2001年09月21日 19:21:45 1.18
--- zipfile.py 2001年11月28日 23:16:40 1.19
***************
*** 455,465 ****
def __del__(self):
"""Call the "close()" method in case the user forgot."""
! if self.fp and not self._filePassed:
! self.fp.close()
! self.fp = None
def close(self):
"""Close the file, and for mode "w" and "a" write the ending
records."""
if self.mode in ("w", "a"): # write ending records
count = 0
--- 455,465 ----
def __del__(self):
"""Call the "close()" method in case the user forgot."""
! self.close()
def close(self):
"""Close the file, and for mode "w" and "a" write the ending
records."""
+ if self.fp is None:
+ return
if self.mode in ("w", "a"): # write ending records
count = 0