Fixed "'NoneType' object is not callable" error in libbe/utility/Dir.__del__
authorW. Trevor King <wking@drexel.edu>
Sun, 23 Nov 2008 12:19:36 +0000 (07:19 -0500)
committerW. Trevor King <wking@drexel.edu>
Sun, 23 Nov 2008 12:19:36 +0000 (07:19 -0500)
libbe/utility.py

index 3f69a9539d6889b411c8f5d535b949b62799a17f..7c1d10aca4f31d27fe3283283e873586aee555a9 100644 (file)
@@ -101,11 +101,14 @@ class Dir (object):
     "A temporary directory for testing use"
     def __init__(self):
         self.path = tempfile.mkdtemp(prefix="BEtest")
-        self.shutil = shutil # save local reference for __del__
+        self.rmtree = shutil.rmtree # save local reference for __del__
+        self.removed = False
     def __del__(self):
         self.cleanup()
     def cleanup(self):
-        self.shutil.rmtree(self.path)
+        if self.removed == False:
+            self.rmtree(self.path)
+            self.removed = True
     def __call__(self):
         return self.path