summaryrefslogtreecommitdiff
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
commitedf6b1e6e59143ce421283ed9a7c182790363ecf (patch)
tree53add6910b0f5d1a751a2038897653288f8281ef
parent4eb09f1e6ea58f5d09fa5d267a3a992762d2b4ed (diff)
downloadpylint-git-edf6b1e6e59143ce421283ed9a7c182790363ecf.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
-rw-r--r--utils.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/utils.py b/utils.py
index d3c92f87b..5e26c3d6b 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)