From 9d903667b88f3d49559df07d311821248109a2ef Mon Sep 17 00:00:00 2001 From: Emile Anclin Date: Mon, 22 Nov 2010 16:04:50 +0100 Subject: 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 --- utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'utils.py') 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) -- cgit v1.2.1