[Python-checkins] CVS: python/dist/src/Lib tempfile.py,1.32,1.33
Tim Peters
tim_one@users.sourceforge.net
Tue, 18 Dec 2001 14:32:42 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv13350/python/Lib
Modified Files:
tempfile.py
Log Message:
TemporaryFileWrapper: cache the value of os.unlink for use by __del__,
to prevent mysterious errors at shutdown due to "os.unlink" turning into
"None.unlink".
Index: tempfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** tempfile.py 2001/10/29 21:46:08 1.32
--- tempfile.py 2001/12/18 22:32:40 1.33
***************
*** 129,132 ****
--- 129,139 ----
no longer needed.
"""
+
+ # Cache the unlinker so we don't get spurious errors at shutdown
+ # when the module-level "os" in None'd out. Note that this must
+ # be referenced as self.unlink, because the name TemporaryFileWrapper
+ # may also get None'd out before __del__ is called.
+ unlink = os.unlink
+
def __init__(self, file, path):
self.file = file
***************
*** 138,142 ****
self.close_called = 1
self.file.close()
! os.unlink(self.path)
def __del__(self):
--- 145,149 ----
self.close_called = 1
self.file.close()
! self.unlink(self.path)
def __del__(self):