[kupfer] If we encounter a module with 'None' code, return early



commit 672db52795fec95b3ab61ed30ee53fdb9121a0dc
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Mar 22 20:39:14 2010 +0100

    If we encounter a module with 'None' code, return early
    
    If we have a stale .pyc (or .pyo?) file from the wrong Python file,
    and no present .py file for a plugin, then loader.get_code() for that
    module will return None. If we get a None code object we have to skip
    that module.
    
    This fixes a bug reported by Chmouel Boudjnah
    
    https://bugs.launchpad.net/bugs/544289

 kupfer/core/plugins.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/core/plugins.py b/kupfer/core/plugins.py
index 0aa365b..25be53a 100644
--- a/kupfer/core/plugins.py
+++ b/kupfer/core/plugins.py
@@ -171,6 +171,10 @@ def _import_plugin_fake(modpath, error=None):
 	if not loader:
 		return None
 
+	code = loader.get_code(modpath)
+	if not code:
+		return None
+
 	try:
 		filename = loader.get_filename()
 	except AttributeError:
@@ -183,7 +187,7 @@ def _import_plugin_fake(modpath, error=None):
 		"__name__": modpath,
 		"__file__": filename,
 	}
-	code = _truncate_code(loader.get_code(modpath), info_attributes)
+	code = _truncate_code(code, info_attributes)
 	try:
 		eval(code, env)
 	except Exception, exc:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]