Skip to content

Commit

Permalink
Portable Python script across version
Browse files Browse the repository at this point in the history
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

llvm-svn: 348127
  • Loading branch information
serge-sans-paille-qb committed Dec 3, 2018
1 parent 3de4108 commit 09616bd
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 32 deletions.
18 changes: 9 additions & 9 deletions clang/bindings/python/clang/cindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def spelling(self):

@property
def ranges(self):
class RangeIterator:
class RangeIterator(object):
def __init__(self, diag):
self.diag = diag

Expand All @@ -416,7 +416,7 @@ def __getitem__(self, key):

@property
def fixits(self):
class FixItIterator:
class FixItIterator(object):
def __init__(self, diag):
self.diag = diag

Expand All @@ -436,7 +436,7 @@ def __getitem__(self, key):

@property
def children(self):
class ChildDiagnosticsIterator:
class ChildDiagnosticsIterator(object):
def __init__(self, diag):
self.diag_set = conf.lib.clang_getChildDiagnostics(diag)

Expand Down Expand Up @@ -2475,8 +2475,8 @@ class _CXUnsavedFile(Structure):
# 20: CompletionChunk.Kind("VerticalSpace")
}

class CompletionChunk:
class Kind:
class CompletionChunk(object):
class Kind(object):
def __init__(self, name):
self.name = name

Expand Down Expand Up @@ -2563,7 +2563,7 @@ def isKindResultType(self):
20: CompletionChunk.Kind("VerticalSpace")}

class CompletionString(ClangObject):
class Availability:
class Availability(object):
def __init__(self, name):
self.name = name

Expand Down Expand Up @@ -2656,7 +2656,7 @@ def results(self):

@property
def diagnostics(self):
class DiagnosticsItr:
class DiagnosticsItr(object):
def __init__(self, ccr):
self.ccr= ccr

Expand Down Expand Up @@ -2958,7 +2958,7 @@ def diagnostics(self):
"""
Return an iterable (and indexable) object containing the diagnostics.
"""
class DiagIterator:
class DiagIterator(object):
def __init__(self, tu):
self.tu = tu

Expand Down Expand Up @@ -4090,7 +4090,7 @@ def register(item):
for f in functionList:
register(f)

class Config:
class Config(object):
library_path = None
library_file = None
compatibility_check = True
Expand Down
12 changes: 6 additions & 6 deletions clang/docs/tools/dump_format_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def indent(text, columns, indent_first_line=True):
return s
return indent + s

class Option:
class Option(object):
def __init__(self, name, type, comment):
self.name = name
self.type = type
Expand All @@ -50,7 +50,7 @@ def __str__(self):
2)
return s

class NestedStruct:
class NestedStruct(object):
def __init__(self, name, comment):
self.name = name
self.comment = comment.strip()
Expand All @@ -59,7 +59,7 @@ def __init__(self, name, comment):
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()
Expand All @@ -69,7 +69,7 @@ def __str__(self):
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()
Expand All @@ -78,7 +78,7 @@ def __init__(self, name, comment):
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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions clang/tools/scan-view/share/Reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, value):

# Collect information about a bug.

class BugReport:
class BugReport(object):
def __init__(self, title, description, files):
self.title = title
self.description = description
Expand All @@ -37,7 +37,7 @@ def __init__(self, title, description, files):
# ReporterParameter
#===------------------------------------------------------------------------===#

class ReporterParameter:
class ReporterParameter(object):
def __init__(self, n):
self.name = n
def getName(self):
Expand Down Expand Up @@ -75,7 +75,7 @@ def getHTML(self,r,bugtype,getConfigOption):
# Reporters
#===------------------------------------------------------------------------===#

class EmailReporter:
class EmailReporter(object):
def getName(self):
return 'Email'

Expand Down Expand Up @@ -143,7 +143,7 @@ def fileReport(self, report, parameters):

return "Message sent!"

class BugzillaReporter:
class BugzillaReporter(object):
def getName(self):
return 'Bugzilla'

Expand Down Expand Up @@ -174,7 +174,7 @@ def getValue(self,r,bugtype,getConfigOption):
else:
return '7'

class RadarReporter:
class RadarReporter(object):
@staticmethod
def isAvailable():
# FIXME: Find this .scpt better
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/scan-view/share/ScanView.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def send_open_report(self, report):
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()
Expand Down
2 changes: 1 addition & 1 deletion clang/utils/ABITest/ABITestGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

####

class TypePrinter:
class TypePrinter(object):
def __init__(self, output, outputHeader=None,
outputTests=None, outputDriver=None,
headerName=None, info=None):
Expand Down
2 changes: 1 addition & 1 deletion clang/utils/ABITest/TypeGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
###
# Actual type types

class Type:
class Type(object):
def isBitField(self):
return False

Expand Down
10 changes: 5 additions & 5 deletions clang/utils/analyzer/CmpRuns.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

STATS_REGEXP = re.compile(r"Statistics: (\{.+\})", re.MULTILINE | re.DOTALL)

class Colors:
class Colors(object):
"""
Color for terminal highlight.
"""
Expand All @@ -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']
Expand Down Expand Up @@ -117,14 +117,14 @@ def getRawData(self):
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
Expand Down
6 changes: 3 additions & 3 deletions clang/utils/modfuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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
Expand All @@ -39,7 +39,7 @@ def apply(self, model, name):
Decl('X %(name)s;\n', depends=['X']),
]

class FS:
class FS(object):
def __init__(self):
self.fs = {}
self.prevfs = {}
Expand All @@ -62,7 +62,7 @@ def done(self):

fs = FS()

class CodeModel:
class CodeModel(object):
def __init__(self):
self.source = ''
self.modules = {}
Expand Down
2 changes: 1 addition & 1 deletion clang/utils/token-delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def search(self, c, sets):

###

class Token:
class Token(object):
def __init__(self, type, data, flags, file, line, column):
self.type = type
self.data = data
Expand Down

0 comments on commit 09616bd

Please sign in to comment.