r348127 - Portable Python script across version

Serge Guelton via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 3 04:12:49 PST 2018


Author: serge_sans_paille
Date: Mon Dec  3 04:12:48 2018
New Revision: 348127

URL: http://llvm.org/viewvc/llvm-project?rev=348127&view=rev
Log:
Portable Python script across version

Have all classes derive from object: that's implicitly the default in Python3,
it needs to be done explicilty in Python2.

Differential Revision: https://reviews.llvm.org/D55121

Modified:
    cfe/trunk/bindings/python/clang/cindex.py
    cfe/trunk/docs/tools/dump_format_style.py
    cfe/trunk/tools/scan-view/share/Reporter.py
    cfe/trunk/tools/scan-view/share/ScanView.py
    cfe/trunk/utils/ABITest/ABITestGen.py
    cfe/trunk/utils/ABITest/TypeGen.py
    cfe/trunk/utils/analyzer/CmpRuns.py
    cfe/trunk/utils/modfuzz.py
    cfe/trunk/utils/token-delta.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=348127&r1=348126&r2=348127&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Dec  3 04:12:48 2018
@@ -400,7 +400,7 @@ class Diagnostic(object):
 
     @property
     def ranges(self):
-        class RangeIterator:
+        class RangeIterator(object):
             def __init__(self, diag):
                 self.diag = diag
 
@@ -416,7 +416,7 @@ class Diagnostic(object):
 
     @property
     def fixits(self):
-        class FixItIterator:
+        class FixItIterator(object):
             def __init__(self, diag):
                 self.diag = diag
 
@@ -436,7 +436,7 @@ class Diagnostic(object):
 
     @property
     def children(self):
-        class ChildDiagnosticsIterator:
+        class ChildDiagnosticsIterator(object):
             def __init__(self, diag):
                 self.diag_set = conf.lib.clang_getChildDiagnostics(diag)
 
@@ -2475,8 +2475,8 @@ SpellingCache = {
             # 20: CompletionChunk.Kind("VerticalSpace")
 }
 
-class CompletionChunk:
-    class Kind:
+class CompletionChunk(object):
+    class Kind(object):
         def __init__(self, name):
             self.name = name
 
@@ -2563,7 +2563,7 @@ completionChunkKindMap = {
             20: CompletionChunk.Kind("VerticalSpace")}
 
 class CompletionString(ClangObject):
-    class Availability:
+    class Availability(object):
         def __init__(self, name):
             self.name = name
 
@@ -2656,7 +2656,7 @@ class CodeCompletionResults(ClangObject)
 
     @property
     def diagnostics(self):
-        class DiagnosticsItr:
+        class DiagnosticsItr(object):
             def __init__(self, ccr):
                 self.ccr= ccr
 
@@ -2958,7 +2958,7 @@ class TranslationUnit(ClangObject):
         """
         Return an iterable (and indexable) object containing the diagnostics.
         """
-        class DiagIterator:
+        class DiagIterator(object):
             def __init__(self, tu):
                 self.tu = tu
 
@@ -4090,7 +4090,7 @@ def register_functions(lib, ignore_error
     for f in functionList:
         register(f)
 
-class Config:
+class Config(object):
     library_path = None
     library_file = None
     compatibility_check = True

Modified: cfe/trunk/docs/tools/dump_format_style.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_format_style.py?rev=348127&r1=348126&r2=348127&view=diff
==============================================================================
--- cfe/trunk/docs/tools/dump_format_style.py (original)
+++ cfe/trunk/docs/tools/dump_format_style.py Mon Dec  3 04:12:48 2018
@@ -32,7 +32,7 @@ def indent(text, columns, indent_first_l
     return s
   return indent + s
 
-class Option:
+class Option(object):
   def __init__(self, name, type, comment):
     self.name = name
     self.type = type
@@ -50,7 +50,7 @@ class Option:
                   2)
     return s
 
-class NestedStruct:
+class NestedStruct(object):
   def __init__(self, name, comment):
     self.name = name
     self.comment = comment.strip()
@@ -59,7 +59,7 @@ class NestedStruct:
   def __str__(self):
     return '\n'.join(map(str, self.values))
 
-class NestedField:
+class NestedField(object):
   def __init__(self, name, comment):
     self.name = name
     self.comment = comment.strip()
@@ -69,7 +69,7 @@ class NestedField:
         self.name,
         doxygen2rst(indent(self.comment, 2, indent_first_line=False)))
 
-class Enum:
+class Enum(object):
   def __init__(self, name, comment):
     self.name = name
     self.comment = comment.strip()
@@ -78,7 +78,7 @@ class Enum:
   def __str__(self):
     return '\n'.join(map(str, self.values))
 
-class EnumValue:
+class EnumValue(object):
   def __init__(self, name, comment):
     self.name = name
     self.comment = comment
@@ -101,7 +101,7 @@ def clean_comment_line(line):
   return line[4:] + '\n'
 
 def read_options(header):
-  class State:
+  class State(object):
     BeforeStruct, Finished, InStruct, InNestedStruct, InNestedFieldComent, \
     InFieldComment, InEnum, InEnumMemberComment = range(8)
   state = State.BeforeStruct

Modified: cfe/trunk/tools/scan-view/share/Reporter.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/Reporter.py?rev=348127&r1=348126&r2=348127&view=diff
==============================================================================
--- cfe/trunk/tools/scan-view/share/Reporter.py (original)
+++ cfe/trunk/tools/scan-view/share/Reporter.py Mon Dec  3 04:12:48 2018
@@ -16,7 +16,7 @@ class ReportFailure(Exception):
 
 # Collect information about a bug.
 
-class BugReport:
+class BugReport(object):
     def __init__(self, title, description, files):
         self.title = title
         self.description = description
@@ -37,7 +37,7 @@ from email.mime.text import MIMEText
 # ReporterParameter
 #===------------------------------------------------------------------------===#
 
-class ReporterParameter:
+class ReporterParameter(object):
   def __init__(self, n):
     self.name = n
   def getName(self):
@@ -75,7 +75,7 @@ class SelectionParameter (ReporterParame
 # Reporters
 #===------------------------------------------------------------------------===#
 
-class EmailReporter:
+class EmailReporter(object):
     def getName(self):
         return 'Email'
 
@@ -143,7 +143,7 @@ Description: %s
 
         return "Message sent!"
 
-class BugzillaReporter:
+class BugzillaReporter(object):
     def getName(self):
         return 'Bugzilla'
     
@@ -174,7 +174,7 @@ class RadarClassificationParameter(Selec
     else:
       return '7'
 
-class RadarReporter:
+class RadarReporter(object):
     @staticmethod
     def isAvailable():
         # FIXME: Find this .scpt better

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=348127&r1=348126&r2=348127&view=diff
==============================================================================
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Mon Dec  3 04:12:48 2018
@@ -422,7 +422,7 @@ Submit</h3>
         return self.send_string(res, 'text/plain')
 
     def get_report_context(self, report):
-        class Context:
+        class Context(object):
             pass
         if report is None or report == 'None':
             data = self.load_crashes()

Modified: cfe/trunk/utils/ABITest/ABITestGen.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/ABITestGen.py?rev=348127&r1=348126&r2=348127&view=diff
==============================================================================
--- cfe/trunk/utils/ABITest/ABITestGen.py (original)
+++ cfe/trunk/utils/ABITest/ABITestGen.py Mon Dec  3 04:12:48 2018
@@ -10,7 +10,7 @@ from TypeGen import *
 
 ####
 
-class TypePrinter:
+class TypePrinter(object):
     def __init__(self, output, outputHeader=None, 
                  outputTests=None, outputDriver=None,
                  headerName=None, info=None):

Modified: cfe/trunk/utils/ABITest/TypeGen.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/TypeGen.py?rev=348127&r1=348126&r2=348127&view=diff
==============================================================================
--- cfe/trunk/utils/ABITest/TypeGen.py (original)
+++ cfe/trunk/utils/ABITest/TypeGen.py Mon Dec  3 04:12:48 2018
@@ -17,7 +17,7 @@ from Enumeration import *
 ###
 # Actual type types
 
-class Type:
+class Type(object):
     def isBitField(self):
         return False
 

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=348127&r1=348126&r2=348127&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Mon Dec  3 04:12:48 2018
@@ -38,7 +38,7 @@ import sys
 
 STATS_REGEXP = re.compile(r"Statistics: (\{.+\})", re.MULTILINE | re.DOTALL)
 
-class Colors:
+class Colors(object):
     """
     Color for terminal highlight.
     """
@@ -50,14 +50,14 @@ class Colors:
 # path - the analysis output directory
 # root - the name of the root directory, which will be disregarded when
 # determining the source file name
-class SingleRunInfo:
+class SingleRunInfo(object):
     def __init__(self, path, root="", verboseLog=None):
         self.path = path
         self.root = root.rstrip("/\\")
         self.verboseLog = verboseLog
 
 
-class AnalysisDiagnostic:
+class AnalysisDiagnostic(object):
     def __init__(self, data, report, htmlReport):
         self._data = data
         self._loc = self._data['location']
@@ -117,14 +117,14 @@ class AnalysisDiagnostic:
         return self._data
 
 
-class AnalysisReport:
+class AnalysisReport(object):
     def __init__(self, run, files):
         self.run = run
         self.files = files
         self.diagnostics = []
 
 
-class AnalysisRun:
+class AnalysisRun(object):
     def __init__(self, info):
         self.path = info.path
         self.root = info.root

Modified: cfe/trunk/utils/modfuzz.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/modfuzz.py?rev=348127&r1=348126&r2=348127&view=diff
==============================================================================
--- cfe/trunk/utils/modfuzz.py (original)
+++ cfe/trunk/utils/modfuzz.py Mon Dec  3 04:12:48 2018
@@ -12,7 +12,7 @@ import os
 clang = sys.argv[1]
 none_opts = 0.3
 
-class Decl:
+class Decl(object):
   def __init__(self, text, depends=[], provides=[], conflicts=[]):
     self.text = text
     self.depends = depends
@@ -39,7 +39,7 @@ decls = [
   Decl('X %(name)s;\n', depends=['X']),
 ]
 
-class FS:
+class FS(object):
   def __init__(self):
     self.fs = {}
     self.prevfs = {}
@@ -62,7 +62,7 @@ class FS:
 
 fs = FS()
 
-class CodeModel:
+class CodeModel(object):
   def __init__(self):
     self.source = ''
     self.modules = {}

Modified: cfe/trunk/utils/token-delta.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/token-delta.py?rev=348127&r1=348126&r2=348127&view=diff
==============================================================================
--- cfe/trunk/utils/token-delta.py (original)
+++ cfe/trunk/utils/token-delta.py Mon Dec  3 04:12:48 2018
@@ -94,7 +94,7 @@ class DeltaAlgorithm(object):
 
 ###
 
-class Token:
+class Token(object):
     def __init__(self, type, data, flags, file, line, column):
         self.type   = type
         self.data   = data




More information about the cfe-commits mailing list