diff options
author | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2013-02-22 16:10:04 +0100 |
---|---|---|
committer | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2013-02-22 16:10:04 +0100 |
commit | abeafad3d1503dcaa0586369dfe591fb9dd3a466 (patch) | |
tree | 48a0629ae7cd1e9880ff1d2497233baf0f3f32ed | |
parent | c5270c2c909725f2523ba8cf23892ca9e99bd79e (diff) | |
download | pylint-git-abeafad3d1503dcaa0586369dfe591fb9dd3a466.tar.gz |
use load_module_from_file rather than relative import broken in python 3.3. Closes #110213
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | checkers/__init__.py | 11 |
2 files changed, 14 insertions, 8 deletions
@@ -18,10 +18,10 @@ ChangeLog for PyLint 'disable-all' inline directive in favour of 'skip-file' (patch by A.Fayolle) - * #110840: Add messages I0020 and I0021 for reporting of suppressed messages + * #110840: add messages I0020 and I0021 for reporting of suppressed messages and useless suppression pragmas. (patch by Torsten Marek) - * #112728: Add warning E0604 for non-string objects in __all__ + * #112728: add warning E0604 for non-string objects in __all__ (patch by Torsten Marek) * #113231: logging checker now looks at instances of Logger classes @@ -31,6 +31,13 @@ ChangeLog for PyLint which is not octal in Python (patch by Martin Pool) -- + * Python 3 related changes: + + * #110213: fix import of checkers broken with python 3.3, causing + "No such message id W0704" breakage + + * #120635: redefine cmp function used in pylint.reporters + * #115580: fix erroneous W0212 (access to protected member) on super call (patch by Martin Pool) diff --git a/checkers/__init__.py b/checkers/__init__.py index 519e43f63..299078af0 100644 --- a/checkers/__init__.py +++ b/checkers/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE). +# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE). # http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This program is free software; you can redistribute it and/or modify it under @@ -43,6 +43,7 @@ from os import listdir from os.path import dirname, join, isdir, splitext from logilab.astng.utils import ASTWalker +from logilab.common.modutils import load_module_from_file from logilab.common.configuration import OptionsProviderMixIn from pylint.reporters import diff_string, EmptyReport @@ -101,7 +102,6 @@ class BaseChecker(OptionsProviderMixIn, ASTWalker): """return the base directory for the analysed package""" return dirname(self.linter.base_file) - # dummy methods implementing the IChecker interface def open(self): @@ -110,6 +110,7 @@ class BaseChecker(OptionsProviderMixIn, ASTWalker): def close(self): """called after visiting project (i.e set of modules)""" + class BaseRawChecker(BaseChecker): """base class for raw checkers""" @@ -139,17 +140,15 @@ def package_load(linter, directory): """load all module and package in the given directory, looking for a 'register' function in each one, used to register pylint checkers """ - globs = globals() imported = {} for filename in listdir(directory): basename, extension = splitext(filename) if basename in imported or basename == '__pycache__': continue if extension in PY_EXTS and basename != '__init__' or ( - not extension and basename != 'CVS' and - isdir(join(directory, basename))): + not extension and isdir(join(directory, basename))): try: - module = __import__(basename, globs, globs, None) + module = load_module_from_file(join(directory, filename)) except ValueError: # empty module name (usually emacs auto-save files) continue |