atomictempfile: fix exception in __del__ if mktempcopy fails (self._fp is None)
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sat, 13 Jun 2009 13:14:02 +0200
changeset 8785 7a9151bc5b37
parent 8784 9154c79c67cc
child 8786 55af9be4efac
atomictempfile: fix exception in __del__ if mktempcopy fails (self._fp is None) Make what is going on more obvious by explicitely getting the 'closed' attribute from _fp, instead of from the gettatr proxy.
mercurial/util.py
--- a/mercurial/util.py	Thu Jun 11 12:23:08 2009 -0700
+++ b/mercurial/util.py	Sat Jun 13 13:14:02 2009 +0200
@@ -767,17 +767,18 @@
         return getattr(self._fp, name)
 
     def rename(self):
-        if not self.closed:
+        if not self._fp.closed:
             self._fp.close()
             rename(self.temp, localpath(self.__name))
 
     def __del__(self):
-        if not self.closed:
+        if not self._fp:
+            return
+        if not self._fp.closed:
             try:
                 os.unlink(self.temp)
             except: pass
-            if self._fp:
-                self._fp.close()
+            self._fp.close()
 
 def makedirs(name, mode=None):
     """recursive directory creation with parent mode inheritance"""