check if an addon exists before getting its mtime
authorCampbell Barton <ideasman42@gmail.com>
Sat, 26 Nov 2011 17:41:56 +0000 (17:41 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 26 Nov 2011 17:41:56 +0000 (17:41 +0000)
release/scripts/modules/addon_utils.py

index de662b47c4dc65444724c6f38d7daccefd34c22d..21f856a1396020215dd027976713bfed3f4cb4cd 100644 (file)
@@ -235,7 +235,8 @@ def enable(module_name, default_set=True):
 
     # reload if the mtime changes
     mod = sys.modules.get(module_name)
-    if mod:
+    # chances of the file _not_ existing are low, but it could be removed
+    if mod and os.path.exists(mod.__file__):
         mod.__addon_enabled__ = False
         mtime_orig = getattr(mod, "__time__", 0)
         mtime_new = os.path.getmtime(mod.__file__)
@@ -252,6 +253,7 @@ def enable(module_name, default_set=True):
 
     # Split registering up into 3 steps so we can undo
     # if it fails par way through.
+
     # 1) try import
     try:
         mod = __import__(module_name)