Thu, 16 Jan 2014 18:45:45 +0100
Fixed some dubious code related to AST generation.
--- a/Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py Thu Jan 16 18:28:34 2014 +0100 +++ b/Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py Thu Jan 16 18:45:45 2014 +0100 @@ -24,8 +24,6 @@ from PyQt4.QtCore import QT_TRANSLATE_NOOP, QCoreApplication -PyCF_ONLY_AST = 1024 - class DocStyleContext(object): """ @@ -470,7 +468,7 @@ return try: - compile(''.join(self.__source), '', 'exec', PyCF_ONLY_AST) + compile(''.join(self.__source), '', 'exec', ast.PyCF_ONLY_AST) except (SyntaxError, TypeError): self.__reportInvalidSyntax() return
--- a/Plugins/CheckerPlugins/CodeStyleChecker/pep8.py Thu Jan 16 18:28:34 2014 +0100 +++ b/Plugins/CheckerPlugins/CodeStyleChecker/pep8.py Thu Jan 16 18:45:45 2014 +0100 @@ -68,6 +68,7 @@ import inspect import keyword import tokenize +import ast from optparse import OptionParser from fnmatch import fnmatch try: @@ -93,7 +94,6 @@ 'pylint': '%(path)s:%(row)d: [%(code)s] %(text)s', } -PyCF_ONLY_AST = 1024 SINGLETONS = frozenset(['False', 'None', 'True']) KEYWORDS = frozenset(keyword.kwlist + ['print']) - SINGLETONS UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-']) @@ -1509,7 +1509,7 @@ def check_ast(self): try: - tree = compile(''.join(self.lines), '', 'exec', PyCF_ONLY_AST) + tree = compile(''.join(self.lines), '', 'exec', ast.PyCF_ONLY_AST) except (SyntaxError, TypeError): return self.report_invalid_syntax() for name, cls, _ in self._ast_checks:
--- a/UtilitiesPython2/pep8.py Thu Jan 16 18:28:34 2014 +0100 +++ b/UtilitiesPython2/pep8.py Thu Jan 16 18:45:45 2014 +0100 @@ -68,6 +68,7 @@ import inspect import keyword import tokenize +import ast from optparse import OptionParser from fnmatch import fnmatch try: @@ -91,7 +92,6 @@ 'pylint': '%(path)s:%(row)d: [%(code)s] %(text)s', } -PyCF_ONLY_AST = 1024 SINGLETONS = frozenset(['False', 'None', 'True']) KEYWORDS = frozenset(keyword.kwlist + ['print']) - SINGLETONS UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-']) @@ -1351,7 +1351,7 @@ def check_ast(self): try: - tree = compile(''.join(self.lines), '', 'exec', PyCF_ONLY_AST) + tree = compile(''.join(self.lines), '', 'exec', ast.PyCF_ONLY_AST) except (SyntaxError, TypeError): return self.report_invalid_syntax() for name, cls, _ in self._ast_checks: