changeset 8785:7a9151bc5b37

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.
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 13 Jun 2009 13:14:02 +0200
parents 9154c79c67cc
children 55af9be4efac
files mercurial/util.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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"""