[Python-checkins] CVS: python/dist/src/Lib tempfile.py,1.31,1.32
Tim Peters
tim_one@users.sourceforge.net
Mon, 29 Oct 2001 13:46:10 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv10684/python/Lib
Modified Files:
tempfile.py
Log Message:
SF bug #476138: tempfile behavior across platforms
Ensure that a tempfile can be closed any number of times without error.
This wasn't true on Windows.
Index: tempfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** tempfile.py 2001/10/24 20:33:34 1.31
--- tempfile.py 2001/10/29 21:46:08 1.32
***************
*** 132,143 ****
self.file = file
self.path = path
def close(self):
! self.file.close()
! os.unlink(self.path)
def __del__(self):
! try: self.close()
! except: pass
def __getattr__(self, name):
--- 132,145 ----
self.file = file
self.path = path
+ self.close_called = 0
def close(self):
! if not self.close_called:
! self.close_called = 1
! self.file.close()
! os.unlink(self.path)
def __del__(self):
! self.close()
def __getattr__(self, name):