mercurial/bundlerepo.py
changeset 3419 b19360aa21e9
parent 2740 386f04d6ecb3
child 3579 0ed2732aa393
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -233,10 +233,12 @@ class bundlerepository(localrepo.localre
         self.bundlefile.close()
 
     def __del__(self):
-        if not self.bundlefile.closed:
-            self.bundlefile.close()
-        if self.tempfile is not None:
-            os.unlink(self.tempfile)
+        bundlefile = getattr(self, 'bundlefile', None)
+        if bundlefile and not bundlefile.closed:
+            bundlefile.close()
+        tempfile = getattr(self, 'tempfile', None)
+        if tempfile is not None:
+            os.unlink(tempfile)
 
 def instance(ui, path, create):
     if create: