Fixed some dubious code related to AST generation.

Thu, 16 Jan 2014 18:45:45 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 16 Jan 2014 18:45:45 +0100
changeset 3210
8f4fe6f76729
parent 3208
884465a61753
child 3211
bb350913a76a

Fixed some dubious code related to AST generation.

Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/CodeStyleChecker/pep8.py file | annotate | diff | comparison | revisions
UtilitiesPython2/pep8.py file | annotate | diff | comparison | revisions
--- 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:

eric ide

mercurial