util: make atomictempfile saner if mktempcopy fails
authorBryan O'Sullivan <bos@serpentine.com>
Thu, 14 May 2009 14:12:32 -0700
changeset 8420 f53bc3e37655
parent 8419 94e07bb8e5dd
child 8421 b6d0fa8c7685
util: make atomictempfile saner if mktempcopy fails
mercurial/util.py
--- a/mercurial/util.py	Thu May 14 23:05:16 2009 +0200
+++ b/mercurial/util.py	Thu May 14 14:12:32 2009 -0700
@@ -971,6 +971,7 @@
     """
     def __init__(self, name, mode, createmode):
         self.__name = name
+        self._fp = None
         self.temp = mktempcopy(name, emptyok=('w' in mode),
                                createmode=createmode)
         self._fp = posixfile(self.temp, mode)
@@ -988,7 +989,8 @@
             try:
                 os.unlink(self.temp)
             except: pass
-            self._fp.close()
+            if self._fp:
+                self._fp.close()
 
 def makedirs(name, mode=None):
     """recursive directory creation with parent mode inheritance"""