summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorEmile Anclin <emile.anclin@logilab.fr>2010-11-22 16:04:50 +0100
committerEmile Anclin <emile.anclin@logilab.fr>2010-11-22 16:04:50 +0100
commit9d903667b88f3d49559df07d311821248109a2ef (patch)
treed7c601852f8dfa8b78ccbbd8d08a52822c4bcc3b /utils.py
parent66587a72395e51e90d157e52637b311a4b7307b7 (diff)
downloadpylint-9d903667b88f3d49559df07d311821248109a2ef.tar.gz
py3k: catch SyntaxError while searching for a file
When loading a module without the file name, Pylint uses lgc.find_module which uses imp.find_module at lgc.modutils l. 606. When doing this with "func_unknown_encoding" in Python 3.x, a syntax error arises, where as in python 2.x, it friendly returns "pylint/test/input/func_unknown_encoding.py". This is a Python bug : http://bugs.python.org/issue10588 and capturing SyntaxError should be removed as soon as possible
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/utils.py b/utils.py
index d3c92f8..5e26c3d 100644
--- a/utils.py
+++ b/utils.py
@@ -445,7 +445,9 @@ def expand_modules(files_or_modules, black_list):
if filepath is None:
errors.append( {'key' : 'F0003', 'mod': modname} )
continue
- except ImportError, ex:
+ except (ImportError, SyntaxError), ex:
+ # FIXME p3k : the SyntaxError is a Python bug and should be
+ # removed as soon as possible http://bugs.python.org/issue10588
errors.append( {'key': 'F0001', 'mod': modname, 'ex': ex} )
continue
filepath = normpath(filepath)