diff --git a/modulefinder.py.orig b/modulefinder.py index 7f2bf8b..cd5f835 100644 --- a/modulefinder.py.orig +++ b/modulefinder.py @@ -287,7 +287,11 @@ class ModuleFinder: self.msgout(2, "load_module ->", m) return m if type == imp.PY_SOURCE: - co = compile(fp.read()+'\n', pathname, 'exec') + try: + co = compile(fp.read()+'\n', pathname, 'exec') + except SyntaxError: + self.msgout(2, "raise ImportError: Syntax error", pathname) + raise ImportError, "Syntax error in %s" % pathname elif type == imp.PY_COMPILED: if fp.read(4) != imp.get_magic(): self.msgout(2, "raise ImportError: Bad magic number", pathname)