serge-sans-paille updated this revision to Diff 176141.
serge-sans-paille added a comment.

Use generic ``from __future__ import `` line whenever it makes sense


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55121/new/

https://reviews.llvm.org/D55121

Files:
  bindings/python/clang/cindex.py
  bindings/python/examples/cindex/cindex-dump.py
  bindings/python/tests/cindex/test_translation_unit.py
  docs/conf.py
  docs/tools/dump_format_style.py
  tools/clang-format/clang-format-diff.py
  tools/clang-format/clang-format-sublime.py
  tools/clang-format/clang-format.py
  tools/clang-format/git-clang-format
  tools/clang-rename/clang-rename.py
  tools/scan-build-py/libscanbuild/arguments.py
  tools/scan-view/share/Reporter.py
  utils/ABITest/ABITestGen.py
  utils/ABITest/Enumeration.py
  utils/CIndex/completion_logger_server.py
  utils/TestUtils/deep-stack.py
  utils/analyzer/SATestAdd.py
  utils/analyzer/SATestUpdateDiffs.py
  utils/analyzer/SumTimerInfo.py
  utils/check_cfc/check_cfc.py
  utils/check_cfc/obj_diff.py
  utils/check_cfc/setup.py
  utils/check_cfc/test_check_cfc.py
  utils/clangdiag.py
  utils/hmaptool/hmaptool
  utils/modfuzz.py
  utils/perf-training/perf-helper.py
  utils/token-delta.py
  www/builtins.py

Index: www/builtins.py
===================================================================
--- www/builtins.py
+++ www/builtins.py
@@ -151,7 +151,7 @@
   sys.stderr.write("%s:%d: x86 builtin %s used, too many replacements\n" % (fileinput.filename(), fileinput.filelineno(), builtin))
 
 for line in fileinput.input(inplace=1):
-  for builtin, repl in repl_map.iteritems():
+  for builtin, repl in repl_map.items():
     if builtin in line:
       line = line.replace(builtin, repl)
       report_repl(builtin, repl)
Index: utils/token-delta.py
===================================================================
--- utils/token-delta.py
+++ utils/token-delta.py
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 
+from __future__ import absolute_import, division, print_function
 import os
 import re
 import subprocess
@@ -37,7 +38,7 @@
         # O(N^2) case unless user requests it.
         if not force:
             if not self.getTestResult(changes):
-                raise ValueError,'Initial test passed to delta fails.'
+                raise ValueError('Initial test passed to delta fails.')
 
         # Check empty set first to quickly find poor test functions.
         if self.getTestResult(set()):
@@ -94,7 +95,7 @@
 
 ###
 
-class Token:
+class Token(object):
     def __init__(self, type, data, flags, file, line, column):
         self.type   = type
         self.data   = data
@@ -165,7 +166,7 @@
         byFile = self.writeFiles(changes, self.tempFiles)
 
         if self.log:
-            print >>sys.stderr, 'TEST - ',
+            print('TEST - ', end=' ', file=sys.stderr)
             if self.log > 1:
                 for i,(file,_) in enumerate(self.tokenLists):
                     indices = byFile[i]
@@ -184,8 +185,8 @@
                         sys.stderr.write(str(byFile[i][-1]))
                     sys.stderr.write('] ')
             else:
-                print >>sys.stderr, ', '.join(['%s:%d tokens' % (file, len(byFile[i]))
-                                               for i,(file,_) in enumerate(self.tokenLists)]),
+                print(', '.join(['%s:%d tokens' % (file, len(byFile[i]))
+                                               for i,(file,_) in enumerate(self.tokenLists)]), end=' ', file=sys.stderr)
 
         p = subprocess.Popen([self.testProgram] + self.tempFiles)
         res = p.wait() == 0
@@ -194,10 +195,10 @@
             self.writeFiles(changes, self.targetFiles)
 
         if self.log:
-            print >>sys.stderr, '=> %s' % res
+            print('=> %s' % res, file=sys.stderr)
         else:
             if res:
-                print '\nSUCCESS (%d tokens)' % len(changes)
+                print('\nSUCCESS (%d tokens)' % len(changes))
             else:                
                 sys.stderr.write('.')
 
@@ -209,7 +210,7 @@
                                           for j in range(len(tokens))])
         self.writeFiles(res, self.targetFiles)
         if not self.log:
-            print >>sys.stderr
+            print(file=sys.stderr)
         return res
 
 def tokenBasedMultiDelta(program, files, log):            
@@ -218,15 +219,15 @@
                   for file in files]
 
     numTokens = sum([len(tokens) for _,tokens in tokenLists])
-    print "Delta on %s with %d tokens." % (', '.join(files), numTokens)
+    print("Delta on %s with %d tokens." % (', '.join(files), numTokens))
     
     tbmd = TMBDDelta(program, tokenLists, log)
 
     res = tbmd.run()
 
-    print "Finished %s with %d tokens (in %d tests)." % (', '.join(tbmd.targetFiles),
+    print("Finished %s with %d tokens (in %d tests)." % (', '.join(tbmd.targetFiles),
                                                          len(res),
-                                                         tbmd.numTests)
+                                                         tbmd.numTests))
         
 def main():
     from optparse import OptionParser, OptionGroup
@@ -247,5 +248,5 @@
     try:
         main()
     except KeyboardInterrupt:
-        print >>sys.stderr,'Interrupted.'
+        print('Interrupted.', file=sys.stderr)
         os._exit(1) # Avoid freeing our giant cache.
Index: utils/perf-training/perf-helper.py
===================================================================
--- utils/perf-training/perf-helper.py
+++ utils/perf-training/perf-helper.py
@@ -7,7 +7,7 @@
 #
 #===------------------------------------------------------------------------===#
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import sys
 import os
@@ -295,8 +295,8 @@
     for a in symbols:
       counts[a] = counts.get(a,0) + 1
 
-  by_count = counts.items()
-  by_count.sort(key = lambda (_,n): -n)
+  by_count = list(counts.items())
+  by_count.sort(key = lambda __n: -__n[1])
   return [s for s,n in by_count]
  
 def form_by_random(symbol_lists):
@@ -333,7 +333,7 @@
     help="write a list of the unordered symbols to PATH (requires --binary)",
     default=None, metavar="PATH")
   parser.add_argument("--method", dest="method",
-    help="order file generation method to use", choices=methods.keys(),
+    help="order file generation method to use", choices=list(methods.keys()),
     default='call_order')
   opts = parser.parse_args(args)
 
Index: utils/modfuzz.py
===================================================================
--- utils/modfuzz.py
+++ utils/modfuzz.py
@@ -4,6 +4,7 @@
 #  1) Update the 'decls' list below with your fuzzing configuration.
 #  2) Run with the clang binary as the command-line argument.
 
+from __future__ import absolute_import, division, print_function
 import random
 import subprocess
 import sys
@@ -12,7 +13,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
@@ -39,7 +40,7 @@
   Decl('X %(name)s;\n', depends=['X']),
 ]
 
-class FS:
+class FS(object):
   def __init__(self):
     self.fs = {}
     self.prevfs = {}
@@ -62,7 +63,7 @@
 
 fs = FS()
 
-class CodeModel:
+class CodeModel(object):
   def __init__(self):
     self.source = ''
     self.modules = {}
@@ -97,7 +98,7 @@
     if not model.fails():
       return
   except KeyboardInterrupt:
-    print
+    print()
     return True
 
   sys.stdout.write('\nReducing:\n')
@@ -106,7 +107,7 @@
   try:
     while True:
       assert m, 'got a failure with no steps; broken clang binary?'
-      i = random.choice(range(len(m)))
+      i = random.choice(list(range(len(m))))
       x = m[0:i] + m[i+1:]
       m2 = CodeModel()
       for d in x:
Index: utils/hmaptool/hmaptool
===================================================================
--- utils/hmaptool/hmaptool
+++ utils/hmaptool/hmaptool
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import json
 import optparse
Index: utils/clangdiag.py
===================================================================
--- utils/clangdiag.py
+++ utils/clangdiag.py
@@ -9,9 +9,9 @@
 #   (lldb) command script import /path/to/clandiag.py
 #----------------------------------------------------------------------
 
+from __future__ import absolute_import, division, print_function
 import lldb
 import argparse
-import commands
 import shlex
 import os
 import re
@@ -189,4 +189,4 @@
     # Add any commands contained in this module to LLDB
     debugger.HandleCommand(
         'command script add -f clangdiag.the_diag_command clangdiag')
-    print 'The "clangdiag" command has been installed, type "help clangdiag" or "clangdiag --help" for detailed help.'
+    print('The "clangdiag" command has been installed, type "help clangdiag" or "clangdiag --help" for detailed help.')
Index: utils/check_cfc/test_check_cfc.py
===================================================================
--- utils/check_cfc/test_check_cfc.py
+++ utils/check_cfc/test_check_cfc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
 
 """Test internal functions within check_cfc.py."""
 
Index: utils/check_cfc/setup.py
===================================================================
--- utils/check_cfc/setup.py
+++ utils/check_cfc/setup.py
@@ -1,6 +1,7 @@
 """For use on Windows. Run with:
     python.exe setup.py py2exe
     """
+from __future__ import absolute_import, division, print_function
 from distutils.core import setup
 try:
     import py2exe
@@ -8,10 +9,10 @@
     import platform
     import sys
     if platform.system() == 'Windows':
-        print "Could not find py2exe. Please install then run setup.py py2exe."
+        print("Could not find py2exe. Please install then run setup.py py2exe.")
         raise
     else:
-        print "setup.py only required on Windows."
+        print("setup.py only required on Windows.")
         sys.exit(1)
 
 setup(
Index: utils/check_cfc/obj_diff.py
===================================================================
--- utils/check_cfc/obj_diff.py
+++ utils/check_cfc/obj_diff.py
@@ -1,6 +1,6 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import argparse
 import difflib
@@ -25,7 +25,7 @@
     if p.returncode or err:
         print("Disassemble failed: {}".format(objfile))
         sys.exit(1)
-    return filter(keep_line, out.split(os.linesep))
+    return [line for line in out.split(os.linesep) if keep_line(line)]
 
 def dump_debug(objfile):
     """Dump all of the debug info from a file."""
@@ -34,7 +34,7 @@
     if p.returncode or err:
         print("Dump debug failed: {}".format(objfile))
         sys.exit(1)
-    return filter(keep_line, out.split(os.linesep))
+    return [line for line in out.split(os.linesep) if keep_line(line)]
 
 def first_diff(a, b, fromfile, tofile):
     """Returns the first few lines of a difference, if there is one.  Python
Index: utils/check_cfc/check_cfc.py
===================================================================
--- utils/check_cfc/check_cfc.py
+++ utils/check_cfc/check_cfc.py
@@ -47,7 +47,7 @@
  subclass.
 """
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import imp
 import os
Index: utils/analyzer/SumTimerInfo.py
===================================================================
--- utils/analyzer/SumTimerInfo.py
+++ utils/analyzer/SumTimerInfo.py
@@ -6,13 +6,14 @@
 Statistics are enabled by passing '-internal-stats' option to scan-build
 (or '-analyzer-stats' to the analyzer).
 """
+from __future__ import absolute_import, division, print_function
 
 import sys
 
 if __name__ == '__main__':
     if len(sys.argv) < 2:
-        print >> sys.stderr, 'Usage: ', sys.argv[0],\
-                             'scan_build_output_file'
+        print('Usage: ', sys.argv[0],\
+                             'scan_build_output_file', file=sys.stderr)
         sys.exit(-1)
 
     f = open(sys.argv[1], 'r')
@@ -65,15 +66,15 @@
             s = line.split()
             TotalTime = TotalTime + float(s[6])
 
-    print "TU Count %d" % (Count)
-    print "Time %f" % (Time)
-    print "Warnings %d" % (Warnings)
-    print "Functions Analyzed %d" % (FunctionsAnalyzed)
-    print "Reachable Blocks %d" % (ReachableBlocks)
-    print "Reached Max Steps %d" % (ReachedMaxSteps)
-    print "Number of Steps %d" % (NumSteps)
-    print "Number of Inlined calls %d (bifurcated %d)" % (
-        NumInlinedCallSites, NumBifurcatedCallSites)
-    print "MaxTime %f" % (MaxTime)
-    print "TotalTime %f" % (TotalTime)
-    print "Max CFG Size %d" % (MaxCFGSize)
+    print("TU Count %d" % (Count))
+    print("Time %f" % (Time))
+    print("Warnings %d" % (Warnings))
+    print("Functions Analyzed %d" % (FunctionsAnalyzed))
+    print("Reachable Blocks %d" % (ReachableBlocks))
+    print("Reached Max Steps %d" % (ReachedMaxSteps))
+    print("Number of Steps %d" % (NumSteps))
+    print("Number of Inlined calls %d (bifurcated %d)" % (
+        NumInlinedCallSites, NumBifurcatedCallSites))
+    print("MaxTime %f" % (MaxTime))
+    print("TotalTime %f" % (TotalTime))
+    print("Max CFG Size %d" % (MaxCFGSize))
Index: utils/analyzer/SATestUpdateDiffs.py
===================================================================
--- utils/analyzer/SATestUpdateDiffs.py
+++ utils/analyzer/SATestUpdateDiffs.py
@@ -3,6 +3,7 @@
 """
 Update reference results for static analyzer.
 """
+from __future__ import absolute_import, division, print_function
 
 import SATestBuild
 
@@ -15,7 +16,7 @@
 
 def runCmd(Command, **kwargs):
     if Verbose:
-        print "Executing %s" % Command
+        print("Executing %s" % Command)
     check_call(Command, shell=True, **kwargs)
 
 
@@ -30,8 +31,8 @@
         SATestBuild.getSBOutputDirName(IsReferenceBuild=False))
 
     if not os.path.exists(CreatedResultsPath):
-        print >> sys.stderr, "New results not found, was SATestBuild.py "\
-                             "previously run?"
+        print("New results not found, was SATestBuild.py "\
+                             "previously run?", file=sys.stderr)
         sys.exit(1)
 
     BuildLogPath = SATestBuild.getBuildLogPath(RefResultsPath)
@@ -62,9 +63,9 @@
 
 def main(argv):
     if len(argv) == 2 and argv[1] in ('-h', '--help'):
-        print >> sys.stderr, "Update static analyzer reference results based "\
+        print("Update static analyzer reference results based "\
                              "\non the previous run of SATestBuild.py.\n"\
-                             "\nN.B.: Assumes that SATestBuild.py was just run"
+                             "\nN.B.: Assumes that SATestBuild.py was just run", file=sys.stderr)
         sys.exit(1)
 
     with SATestBuild.projectFileHandler() as f:
Index: utils/analyzer/SATestAdd.py
===================================================================
--- utils/analyzer/SATestAdd.py
+++ utils/analyzer/SATestAdd.py
@@ -42,6 +42,7 @@
                                           diff -ur CachedSource PatchedSource \
                                               > changes_for_analyzer.patch
 """
+from __future__ import absolute_import, division, print_function
 import SATestBuild
 
 import os
@@ -66,7 +67,7 @@
     CurDir = os.path.abspath(os.curdir)
     Dir = SATestBuild.getProjectDir(ID)
     if not os.path.exists(Dir):
-        print "Error: Project directory is missing: %s" % Dir
+        print("Error: Project directory is missing: %s" % Dir)
         sys.exit(-1)
 
     # Build the project.
@@ -78,30 +79,30 @@
     if os.path.exists(ProjectMapPath):
         FileMode = "r+b"
     else:
-        print "Warning: Creating the Project Map file!!"
+        print("Warning: Creating the Project Map file!!")
         FileMode = "w+b"
 
     with open(ProjectMapPath, FileMode) as PMapFile:
         if (isExistingProject(PMapFile, ID)):
-            print >> sys.stdout, 'Warning: Project with ID \'', ID, \
-                                 '\' already exists.'
-            print >> sys.stdout, "Reference output has been regenerated."
+            print('Warning: Project with ID \'', ID, \
+                                 '\' already exists.', file=sys.stdout)
+            print("Reference output has been regenerated.", file=sys.stdout)
         else:
             PMapWriter = csv.writer(PMapFile)
             PMapWriter.writerow((ID, int(BuildMode)))
-            print "The project map is updated: ", ProjectMapPath
+            print("The project map is updated: ", ProjectMapPath)
 
 
 # TODO: Add an option not to build.
 # TODO: Set the path to the Repository directory.
 if __name__ == '__main__':
     if len(sys.argv) < 2 or sys.argv[1] in ('-h', '--help'):
-        print >> sys.stderr, 'Add a new project for testing to the analyzer'\
+        print('Add a new project for testing to the analyzer'\
                              '\nUsage: ', sys.argv[0],\
                              'project_ID <mode>\n' \
                              'mode: 0 for single file project, ' \
                              '1 for scan_build, ' \
-                             '2 for single file c++11 project'
+                             '2 for single file c++11 project', file=sys.stderr)
         sys.exit(-1)
 
     BuildMode = 1
Index: utils/TestUtils/deep-stack.py
===================================================================
--- utils/TestUtils/deep-stack.py
+++ utils/TestUtils/deep-stack.py
@@ -1,22 +1,23 @@
 #!/usr/bin/env python
 
+from __future__ import absolute_import, division, print_function
 def pcall(f, N):
     if N == 0:
-        print >>f, '    f(0)'
+        print('    f(0)', file=f)
         return
 
-    print >>f, '    f('
+    print('    f(', file=f)
     pcall(f, N - 1)
-    print >>f, '     )'
+    print('     )', file=f)
 
 def main():
     f = open('t.c','w')
-    print >>f, 'int f(int n) { return n; }'
-    print >>f, 'int t() {'
-    print >>f, '  return'
+    print('int f(int n) { return n; }', file=f)
+    print('int t() {', file=f)
+    print('  return', file=f)
     pcall(f, 10000)
-    print >>f, '  ;'
-    print >>f, '}'
+    print('  ;', file=f)
+    print('}', file=f)
 
 if __name__ == "__main__":
     import sys
Index: utils/CIndex/completion_logger_server.py
===================================================================
--- utils/CIndex/completion_logger_server.py
+++ utils/CIndex/completion_logger_server.py
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+from __future__ import absolute_import, division, print_function
 import sys
 from socket import *
 from time import strftime
@@ -6,7 +7,7 @@
 
 def main():
   if len(sys.argv) < 4:
-    print "completion_logger_server.py <listen address> <listen port> <log file>"
+    print("completion_logger_server.py <listen address> <listen port> <log file>")
     exit(1)
 
   host = sys.argv[1]
@@ -18,7 +19,7 @@
   UDPSock = socket(AF_INET,SOCK_DGRAM)
   UDPSock.bind(addr)
   
-  print "Listing on {0}:{1} and logging to '{2}'".format(host, port, sys.argv[3])
+  print("Listing on {0}:{1} and logging to '{2}'".format(host, port, sys.argv[3]))
 
   # Open the logging file.
   f = open(sys.argv[3], "a")
Index: utils/ABITest/Enumeration.py
===================================================================
--- utils/ABITest/Enumeration.py
+++ utils/ABITest/Enumeration.py
@@ -1,5 +1,6 @@
 """Utilities for enumeration of finite and countably infinite sets.
 """
+from __future__ import absolute_import, division, print_function
 ###
 # Countable iteration
 
@@ -17,7 +18,7 @@
         return 1
 
     def __sub__(self, b):
-        raise ValueError,"Cannot subtract aleph0"
+        raise ValueError("Cannot subtract aleph0")
     __rsub__ = __sub__
 
     def __add__(self, b): 
@@ -46,7 +47,8 @@
 def base(line):
     return line*(line+1)//2
 
-def pairToN((x,y)):
+def pairToN(pair):
+    x,y = pair
     line,index = x+y,y
     return base(line)+index
 
@@ -86,9 +88,9 @@
     Return the N-th pair such that 0 <= x < W and 0 <= y < H."""
 
     if W <= 0 or H <= 0:
-        raise ValueError,"Invalid bounds"
+        raise ValueError("Invalid bounds")
     elif N >= W*H:
-        raise ValueError,"Invalid input (out of bounds)"
+        raise ValueError("Invalid input (out of bounds)")
 
     # Simple case...
     if W is aleph0 and H is aleph0:
@@ -170,7 +172,7 @@
     N -= 1
     if maxElement is not aleph0:
         if maxSize is aleph0:
-            raise NotImplementedError,'Max element size without max size unhandled'
+            raise NotImplementedError('Max element size without max size unhandled')
         bounds = [maxElement**i for i in range(1, maxSize+1)]
         S,M = getNthPairVariableBounds(N, bounds)
     else:
@@ -193,12 +195,12 @@
     bounds[x]."""
 
     if not bounds:
-        raise ValueError,"Invalid bounds"
+        raise ValueError("Invalid bounds")
     if not (0 <= N < sum(bounds)):
-        raise ValueError,"Invalid input (out of bounds)"
+        raise ValueError("Invalid input (out of bounds)")
 
     level = 0
-    active = range(len(bounds))
+    active = list(range(len(bounds)))
     active.sort(key=lambda i: bounds[i])
     prevLevel = 0
     for i,index in enumerate(active):
@@ -216,7 +218,7 @@
             N -= levelSize
             prevLevel = level
     else:
-        raise RuntimError,"Unexpected loop completion"
+        raise RuntimError("Unexpected loop completion")
 
 def getNthPairVariableBoundsChecked(N, bounds, GNVP=getNthPairVariableBounds):
     x,y = GNVP(N,bounds)
@@ -233,18 +235,18 @@
     for i in range(min(W*H,40)):
         x,y = getNthPairBounded(i,W,H)
         x2,y2 = getNthPairBounded(i,W,H,useDivmod=True)
-        print i,(x,y),(x2,y2)
+        print(i,(x,y),(x2,y2))
         a[y][x] = '%2d'%i
         b[y2][x2] = '%2d'%i
 
-    print '-- a --'
+    print('-- a --')
     for ln in a[::-1]:
         if ''.join(ln).strip():
-            print '  '.join(ln)
-    print '-- b --'
+            print('  '.join(ln))
+    print('-- b --')
     for ln in b[::-1]:
         if ''.join(ln).strip():
-            print '  '.join(ln)
+            print('  '.join(ln))
 
 def testPairsVB():
     bounds = [2,2,4,aleph0,5,aleph0]
@@ -252,13 +254,13 @@
     b = [['  ' for x in range(15)] for y in range(15)]
     for i in range(min(sum(bounds),40)):
         x,y = getNthPairVariableBounds(i, bounds)
-        print i,(x,y)
+        print(i,(x,y))
         a[y][x] = '%2d'%i
 
-    print '-- a --'
+    print('-- a --')
     for ln in a[::-1]:
         if ''.join(ln).strip():
-            print '  '.join(ln)
+            print('  '.join(ln))
 
 ###
 
Index: utils/ABITest/ABITestGen.py
===================================================================
--- utils/ABITest/ABITestGen.py
+++ utils/ABITest/ABITestGen.py
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 
+from __future__ import absolute_import, division, print_function
 from pprint import pprint
 import random, atexit, time
 from random import randrange
@@ -10,7 +11,7 @@
 
 ####
 
-class TypePrinter:
+class TypePrinter(object):
     def __init__(self, output, outputHeader=None, 
                  outputTests=None, outputDriver=None,
                  headerName=None, info=None):
@@ -28,42 +29,42 @@
         if info:
             for f in (self.output,self.outputHeader,self.outputTests,self.outputDriver):
                 if f:
-                    print >>f,info
+                    print(info, file=f)
 
         if self.writeBody:
-            print >>self.output, '#include <stdio.h>\n'
+            print('#include <stdio.h>\n', file=self.output)
             if self.outputTests:
-                print >>self.outputTests, '#include <stdio.h>'
-                print >>self.outputTests, '#include <string.h>'
-                print >>self.outputTests, '#include <assert.h>\n'
+                print('#include <stdio.h>', file=self.outputTests)
+                print('#include <string.h>', file=self.outputTests)
+                print('#include <assert.h>\n', file=self.outputTests)
 
         if headerName:
             for f in (self.output,self.outputTests,self.outputDriver):
                 if f is not None:
-                    print >>f, '#include "%s"\n'%(headerName,)
+                    print('#include "%s"\n'%(headerName,), file=f)
         
         if self.outputDriver:
-            print >>self.outputDriver, '#include <stdio.h>'
-            print >>self.outputDriver, '#include <stdlib.h>\n'
-            print >>self.outputDriver, 'int main(int argc, char **argv) {'
-            print >>self.outputDriver, '  int index = -1;'
-            print >>self.outputDriver, '  if (argc > 1) index = atoi(argv[1]);'
+            print('#include <stdio.h>', file=self.outputDriver)
+            print('#include <stdlib.h>\n', file=self.outputDriver)
+            print('int main(int argc, char **argv) {', file=self.outputDriver)
+            print('  int index = -1;', file=self.outputDriver)
+            print('  if (argc > 1) index = atoi(argv[1]);', file=self.outputDriver)
             
     def finish(self):
         if self.layoutTests:
-            print >>self.output, 'int main(int argc, char **argv) {'
-            print >>self.output, '  int index = -1;'
-            print >>self.output, '  if (argc > 1) index = atoi(argv[1]);'
+            print('int main(int argc, char **argv) {', file=self.output)
+            print('  int index = -1;', file=self.output)
+            print('  if (argc > 1) index = atoi(argv[1]);', file=self.output)
             for i,f in self.layoutTests:
-                print >>self.output, '  if (index == -1 || index == %d)' % i
-                print >>self.output, '    %s();' % f
-            print >>self.output, '  return 0;'
-            print >>self.output, '}' 
+                print('  if (index == -1 || index == %d)' % i, file=self.output)
+                print('    %s();' % f, file=self.output)
+            print('  return 0;', file=self.output)
+            print('}', file=self.output) 
 
         if self.outputDriver:
-            print >>self.outputDriver, '  printf("DONE\\n");'
-            print >>self.outputDriver, '  return 0;'
-            print >>self.outputDriver, '}'        
+            print('  printf("DONE\\n");', file=self.outputDriver)
+            print('  return 0;', file=self.outputDriver)
+            print('}', file=self.outputDriver)        
 
     def addDeclaration(self, decl):
         if decl in self.declarations:
@@ -71,11 +72,11 @@
 
         self.declarations.add(decl)
         if self.outputHeader:
-            print >>self.outputHeader, decl
+            print(decl, file=self.outputHeader)
         else:
-            print >>self.output, decl
+            print(decl, file=self.output)
             if self.outputTests:
-                print >>self.outputTests, decl
+                print(decl, file=self.outputTests)
         return True
 
     def getTypeName(self, T):
@@ -91,12 +92,12 @@
         tyNameClean = tyName.replace(' ','_').replace('*','star')
         fnName = 'test_%s' % tyNameClean
             
-        print >>self.output,'void %s(void) {' % fnName
+        print('void %s(void) {' % fnName, file=self.output)
         self.printSizeOfType('    %s'%fnName, tyName, ty, self.output)
         self.printAlignOfType('    %s'%fnName, tyName, ty, self.output)
         self.printOffsetsOfType('    %s'%fnName, tyName, ty, self.output)
-        print >>self.output,'}'
-        print >>self.output
+        print('}', file=self.output)
+        print(file=self.output)
         
         self.layoutTests.append((i,fnName))
         
@@ -115,71 +116,71 @@
 
         fnName = 'fn%d'%(FT.index,)
         if self.outputHeader:
-            print >>self.outputHeader,'%s %s(%s);'%(retvalTypeName, fnName, args)
+            print('%s %s(%s);'%(retvalTypeName, fnName, args), file=self.outputHeader)
         elif self.outputTests:
-            print >>self.outputTests,'%s %s(%s);'%(retvalTypeName, fnName, args)
+            print('%s %s(%s);'%(retvalTypeName, fnName, args), file=self.outputTests)
             
-        print >>self.output,'%s %s(%s)'%(retvalTypeName, fnName, args),
+        print('%s %s(%s)'%(retvalTypeName, fnName, args), end=' ', file=self.output)
         if self.writeBody:
-            print >>self.output, '{'
+            print('{', file=self.output)
             
             for i,t in enumerate(FT.argTypes):
                 self.printValueOfType('    %s'%fnName, 'arg%d'%i, t)
 
             if retvalName is not None:
-                print >>self.output, '  return %s;'%(retvalName,)
-            print >>self.output, '}'
+                print('  return %s;'%(retvalName,), file=self.output)
+            print('}', file=self.output)
         else:
-            print >>self.output, '{}'
-        print >>self.output
+            print('{}', file=self.output)
+        print(file=self.output)
 
         if self.outputDriver:
-            print >>self.outputDriver, '  if (index == -1 || index == %d) {' % i
-            print >>self.outputDriver, '    extern void test_%s(void);' % fnName
-            print >>self.outputDriver, '    test_%s();' % fnName
-            print >>self.outputDriver, '   }'
+            print('  if (index == -1 || index == %d) {' % i, file=self.outputDriver)
+            print('    extern void test_%s(void);' % fnName, file=self.outputDriver)
+            print('    test_%s();' % fnName, file=self.outputDriver)
+            print('   }', file=self.outputDriver)
             
         if self.outputTests:
             if self.outputHeader:
-                print >>self.outputHeader, 'void test_%s(void);'%(fnName,)
+                print('void test_%s(void);'%(fnName,), file=self.outputHeader)
 
             if retvalName is None:
                 retvalTests = None
             else:
                 retvalTests = self.getTestValuesArray(FT.returnType)
-            tests = map(self.getTestValuesArray, FT.argTypes)
-            print >>self.outputTests, 'void test_%s(void) {'%(fnName,)
+            tests = [self.getTestValuesArray(ty) for ty in FT.argTypes]
+            print('void test_%s(void) {'%(fnName,), file=self.outputTests)
 
             if retvalTests is not None:
-                print >>self.outputTests, '  printf("%s: testing return.\\n");'%(fnName,)
-                print >>self.outputTests, '  for (int i=0; i<%d; ++i) {'%(retvalTests[1],)
+                print('  printf("%s: testing return.\\n");'%(fnName,), file=self.outputTests)
+                print('  for (int i=0; i<%d; ++i) {'%(retvalTests[1],), file=self.outputTests)
                 args = ', '.join(['%s[%d]'%(t,randrange(l)) for t,l in tests])
-                print >>self.outputTests, '    %s RV;'%(retvalTypeName,)
-                print >>self.outputTests, '    %s = %s[i];'%(retvalName, retvalTests[0])
-                print >>self.outputTests, '    RV = %s(%s);'%(fnName, args)
+                print('    %s RV;'%(retvalTypeName,), file=self.outputTests)
+                print('    %s = %s[i];'%(retvalName, retvalTests[0]), file=self.outputTests)
+                print('    RV = %s(%s);'%(fnName, args), file=self.outputTests)
                 self.printValueOfType('  %s_RV'%fnName, 'RV', FT.returnType, output=self.outputTests, indent=4)
                 self.checkTypeValues('RV', '%s[i]' % retvalTests[0], FT.returnType, output=self.outputTests, indent=4)
-                print >>self.outputTests, '  }'
+                print('  }', file=self.outputTests)
             
             if tests:
-                print >>self.outputTests, '  printf("%s: testing arguments.\\n");'%(fnName,)
+                print('  printf("%s: testing arguments.\\n");'%(fnName,), file=self.outputTests)
             for i,(array,length) in enumerate(tests):
                 for j in range(length):
                     args = ['%s[%d]'%(t,randrange(l)) for t,l in tests]
                     args[i] = '%s[%d]'%(array,j)
-                    print >>self.outputTests, '  %s(%s);'%(fnName, ', '.join(args),)
-            print >>self.outputTests, '}'
+                    print('  %s(%s);'%(fnName, ', '.join(args),), file=self.outputTests)
+            print('}', file=self.outputTests)
 
     def getTestReturnValue(self, type):
         typeName = self.getTypeName(type)        
         info = self.testReturnValues.get(typeName)
         if info is None:
             name = '%s_retval'%(typeName.replace(' ','_').replace('*','star'),)
-            print >>self.output, '%s %s;'%(typeName,name)
+            print('%s %s;'%(typeName,name), file=self.output)
             if self.outputHeader:
-                print >>self.outputHeader, 'extern %s %s;'%(typeName,name)
+                print('extern %s %s;'%(typeName,name), file=self.outputHeader)
             elif self.outputTests:                
-                print >>self.outputTests, 'extern %s %s;'%(typeName,name)
+                print('extern %s %s;'%(typeName,name), file=self.outputTests)
             info = self.testReturnValues[typeName] = name
         return info
 
@@ -188,12 +189,12 @@
         info = self.testValues.get(typeName)
         if info is None:
             name = '%s_values'%(typeName.replace(' ','_').replace('*','star'),)
-            print >>self.outputTests, 'static %s %s[] = {'%(typeName,name)
+            print('static %s %s[] = {'%(typeName,name), file=self.outputTests)
             length = 0
             for item in self.getTestValues(type):
-                print >>self.outputTests, '\t%s,'%(item,)
+                print('\t%s,'%(item,), file=self.outputTests)
                 length += 1
-            print >>self.outputTests,'};'
+            print('};', file=self.outputTests)
             info = self.testValues[typeName] = (name,length)
         return info
 
@@ -230,10 +231,10 @@
                     yield '{ %s }' % v
                 return
 
-            fieldValues = map(list, map(self.getTestValues, nonPadding))
+            fieldValues = [list(v) for v in map(self.getTestValues, nonPadding)]
             for i,values in enumerate(fieldValues):
                 for v in values:
-                    elements = map(random.choice,fieldValues)
+                    elements = [random.choice(fv) for fv in fieldValues]
                     elements[i] = v
                     yield '{ %s }'%(', '.join(elements))
 
@@ -250,19 +251,19 @@
                     elements[i] = v
                     yield '{ %s }'%(', '.join(elements))
         else:
-            raise NotImplementedError,'Cannot make tests values of type: "%s"'%(t,)
+            raise NotImplementedError('Cannot make tests values of type: "%s"'%(t,))
 
     def printSizeOfType(self, prefix, name, t, output=None, indent=2):
-        print >>output, '%*sprintf("%s: sizeof(%s) = %%ld\\n", (long)sizeof(%s));'%(indent, '', prefix, name, name) 
+        print('%*sprintf("%s: sizeof(%s) = %%ld\\n", (long)sizeof(%s));'%(indent, '', prefix, name, name), file=output) 
     def printAlignOfType(self, prefix, name, t, output=None, indent=2):
-        print >>output, '%*sprintf("%s: __alignof__(%s) = %%ld\\n", (long)__alignof__(%s));'%(indent, '', prefix, name, name) 
+        print('%*sprintf("%s: __alignof__(%s) = %%ld\\n", (long)__alignof__(%s));'%(indent, '', prefix, name, name), file=output) 
     def printOffsetsOfType(self, prefix, name, t, output=None, indent=2):
         if isinstance(t, RecordType):
             for i,f in enumerate(t.fields):
                 if f.isBitField():
                     continue
                 fname = 'field%d' % i
-                print >>output, '%*sprintf("%s: __builtin_offsetof(%s, %s) = %%ld\\n", (long)__builtin_offsetof(%s, %s));'%(indent, '', prefix, name, fname, name, fname) 
+                print('%*sprintf("%s: __builtin_offsetof(%s, %s) = %%ld\\n", (long)__builtin_offsetof(%s, %s));'%(indent, '', prefix, name, fname, name, fname), file=output) 
                 
     def printValueOfType(self, prefix, name, t, output=None, indent=2):
         if output is None:
@@ -286,13 +287,13 @@
                 code = 'Lf'
             else:
                 code = 'p'
-            print >>output, '%*sprintf("%s: %s = %%%s\\n", %s);'%(
-                indent, '', prefix, name, code, value_expr)
+            print('%*sprintf("%s: %s = %%%s\\n", %s);'%(
+                indent, '', prefix, name, code, value_expr), file=output)
         elif isinstance(t, EnumType):
-            print >>output, '%*sprintf("%s: %s = %%d\\n", %s);'%(indent, '', prefix, name, name)
+            print('%*sprintf("%s: %s = %%d\\n", %s);'%(indent, '', prefix, name, name), file=output)
         elif isinstance(t, RecordType):
             if not t.fields:
-                print >>output, '%*sprintf("%s: %s (empty)\\n");'%(indent, '', prefix, name) 
+                print('%*sprintf("%s: %s (empty)\\n");'%(indent, '', prefix, name), file=output) 
             for i,f in enumerate(t.fields):
                 if f.isPaddingBitField():
                     continue
@@ -310,16 +311,16 @@
                 else:
                     self.printValueOfType(prefix, '%s[%d]'%(name,i), t.elementType, output=output,indent=indent)                    
         else:
-            raise NotImplementedError,'Cannot print value of type: "%s"'%(t,)
+            raise NotImplementedError('Cannot print value of type: "%s"'%(t,))
 
     def checkTypeValues(self, nameLHS, nameRHS, t, output=None, indent=2):
         prefix = 'foo'
         if output is None:
             output = self.output
         if isinstance(t, BuiltinType):
-            print >>output, '%*sassert(%s == %s);' % (indent, '', nameLHS, nameRHS)
+            print('%*sassert(%s == %s);' % (indent, '', nameLHS, nameRHS), file=output)
         elif isinstance(t, EnumType):
-            print >>output, '%*sassert(%s == %s);' % (indent, '', nameLHS, nameRHS)
+            print('%*sassert(%s == %s);' % (indent, '', nameLHS, nameRHS), file=output)
         elif isinstance(t, RecordType):
             for i,f in enumerate(t.fields):
                 if f.isPaddingBitField():
@@ -343,7 +344,7 @@
                     self.checkTypeValues('%s[%d]'%(nameLHS,i), '%s[%d]'%(nameRHS,i), 
                                          t.elementType, output=output,indent=indent)                    
         else:
-            raise NotImplementedError,'Cannot print value of type: "%s"'%(t,)
+            raise NotImplementedError('Cannot print value of type: "%s"'%(t,))
 
 import sys
 
@@ -642,9 +643,9 @@
     def write(N):
         try:
             FT = ftg.get(N)
-        except RuntimeError,e:
+        except RuntimeError as e:
             if e.args[0]=='maximum recursion depth exceeded':
-                print >>sys.stderr,'WARNING: Skipped %d, recursion limit exceeded (bad arguments?)'%(N,)
+                print('WARNING: Skipped %d, recursion limit exceeded (bad arguments?)'%(N,), file=sys.stderr)
                 return
             raise
         if opts.testLayout:
Index: tools/scan-view/share/Reporter.py
===================================================================
--- tools/scan-view/share/Reporter.py
+++ tools/scan-view/share/Reporter.py
@@ -16,7 +16,7 @@
 
 # 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 @@
 # ReporterParameter
 #===------------------------------------------------------------------------===#
 
-class ReporterParameter:
+class ReporterParameter(object):
   def __init__(self, n):
     self.name = n
   def getName(self):
@@ -75,12 +75,12 @@
 # Reporters
 #===------------------------------------------------------------------------===#
 
-class EmailReporter:
+class EmailReporter(object):
     def getName(self):
         return 'Email'
 
     def getParameters(self):
-        return map(lambda x:TextParameter(x),['To', 'From', 'SMTP Server', 'SMTP Port'])
+        return [TextParameter(x) for x in ['To', 'From', 'SMTP Server', 'SMTP Port']]
 
     # Lifted from python email module examples.
     def attachFile(self, outer, path):
@@ -143,12 +143,12 @@
 
         return "Message sent!"
 
-class BugzillaReporter:
+class BugzillaReporter(object):
     def getName(self):
         return 'Bugzilla'
     
     def getParameters(self):
-        return map(lambda x:TextParameter(x),['URL','Product'])
+        return [TextParameter(x) for x in ['URL','Product']]
 
     def fileReport(self, report, parameters):
         raise NotImplementedError
@@ -174,7 +174,7 @@
     else:
       return '7'
 
-class RadarReporter:
+class RadarReporter(object):
     @staticmethod
     def isAvailable():
         # FIXME: Find this .scpt better
@@ -211,7 +211,7 @@
 
         script = os.path.join(os.path.dirname(__file__),'../share/scan-view/FileRadar.scpt')
         args = ['osascript', script, component, componentVersion, classification, personID, report.title,
-                report.description, diagnosis, config] + map(os.path.abspath, report.files)
+                report.description, diagnosis, config] + [os.path.abspath(f) for f in report.files]
 #        print >>sys.stderr, args
         try:
           p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Index: tools/scan-build-py/libscanbuild/arguments.py
===================================================================
--- tools/scan-build-py/libscanbuild/arguments.py
+++ tools/scan-build-py/libscanbuild/arguments.py
@@ -12,6 +12,7 @@
 It also implements basic validation methods, related to the command.
 Validations are mostly calling specific help methods, or mangling values.
 """
+from __future__ import absolute_import, division, print_function
 
 import os
 import sys
Index: tools/clang-rename/clang-rename.py
===================================================================
--- tools/clang-rename/clang-rename.py
+++ tools/clang-rename/clang-rename.py
@@ -22,7 +22,7 @@
 name if the cursor points to a valid symbol.
 '''
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import vim
 import subprocess
 import sys
Index: tools/clang-format/git-clang-format
===================================================================
--- tools/clang-format/git-clang-format
+++ tools/clang-format/git-clang-format
@@ -23,7 +23,7 @@
 Requires Python 2.7 or Python 3                                                  
 """               
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import argparse
 import collections
 import contextlib
Index: tools/clang-format/clang-format.py
===================================================================
--- tools/clang-format/clang-format.py
+++ tools/clang-format/clang-format.py
@@ -25,7 +25,7 @@
 #
 # It operates on the current, potentially unsaved buffer and does not create
 # or save any files. To revert a formatting, just undo.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import difflib
 import json
Index: tools/clang-format/clang-format-sublime.py
===================================================================
--- tools/clang-format/clang-format-sublime.py
+++ tools/clang-format/clang-format-sublime.py
@@ -12,7 +12,7 @@
 # It operates on the current, potentially unsaved buffer and does not create
 # or save any files. To revert a formatting, just undo.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import sublime
 import sublime_plugin
 import subprocess
Index: tools/clang-format/clang-format-diff.py
===================================================================
--- tools/clang-format/clang-format-diff.py
+++ tools/clang-format/clang-format-diff.py
@@ -21,6 +21,7 @@
   svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
 
 """
+from __future__ import absolute_import, division, print_function
 
 import argparse
 import difflib
@@ -28,9 +29,9 @@
 import subprocess
 import sys
 try:
-  from StringIO import StringIO
+  from io import StringIO
 except ImportError:
-   from io import StringIO
+  from StringIO import StringIO
 
 
 def main():
Index: docs/tools/dump_format_style.py
===================================================================
--- docs/tools/dump_format_style.py
+++ docs/tools/dump_format_style.py
@@ -6,7 +6,6 @@
 import collections
 import os
 import re
-import urllib2
 
 CLANG_DIR = os.path.join(os.path.dirname(__file__), '../..')
 FORMAT_STYLE_FILE = os.path.join(CLANG_DIR, 'include/clang/Format/Format.h')
@@ -32,7 +31,7 @@
     return s
   return indent + s
 
-class Option:
+class Option(object):
   def __init__(self, name, type, comment):
     self.name = name
     self.type = type
@@ -50,7 +49,7 @@
                   2)
     return s
 
-class NestedStruct:
+class NestedStruct(object):
   def __init__(self, name, comment):
     self.name = name
     self.comment = comment.strip()
@@ -59,7 +58,7 @@
   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 +68,7 @@
         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 +77,7 @@
   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 +100,7 @@
   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
@@ -180,9 +179,9 @@
                            'std::vector<std::string>',
                            'std::vector<IncludeCategory>',
                            'std::vector<RawStringFormat>']:
-      if enums.has_key(option.type):
+      if option.type in enums:
         option.enum = enums[option.type]
-      elif nested_structs.has_key(option.type):
+      elif option.type in nested_structs:
         option.nested_struct = nested_structs[option.type]
       else:
         raise Exception('Unknown type: %s' % option.type)
Index: docs/conf.py
===================================================================
--- docs/conf.py
+++ docs/conf.py
@@ -11,6 +11,7 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
+from __future__ import absolute_import, division, print_function
 import sys, os
 from datetime import date
 
@@ -233,14 +234,14 @@
         header = f.readline().rstrip('\n')
 
         if len(header) != len(title):
-            print >>sys.stderr, (
+            print((
                 "error: invalid header in %r (does not match title)" % (
-                    file_subpath,))
+                    file_subpath,)), file=sys.stderr)
         if ' - ' not in title:
-            print >>sys.stderr, (
+            print((
                 ("error: invalid title in %r "
                  "(expected '<name> - <description>')") % (
-                    file_subpath,))
+                    file_subpath,)), file=sys.stderr)
 
         # Split the name out of the title.
         name,description = title.split(' - ', 1)
Index: bindings/python/tests/cindex/test_translation_unit.py
===================================================================
--- bindings/python/tests/cindex/test_translation_unit.py
+++ bindings/python/tests/cindex/test_translation_unit.py
@@ -94,9 +94,9 @@
 
     def test_unsaved_files_2(self):
         try:
-            from StringIO import StringIO
-        except:
             from io import StringIO
+        except:
+            from StringIO import StringIO
         tu = TranslationUnit.from_source('fake.c', unsaved_files = [
                 ('fake.c', StringIO('int x;'))])
         spellings = [c.spelling for c in tu.cursor.get_children()]
Index: bindings/python/examples/cindex/cindex-dump.py
===================================================================
--- bindings/python/examples/cindex/cindex-dump.py
+++ bindings/python/examples/cindex/cindex-dump.py
@@ -79,7 +79,7 @@
     if not tu:
         parser.error("unable to load input")
 
-    pprint(('diags', map(get_diag_info, tu.diagnostics)))
+    pprint(('diags', [get_diag_info(d) for d in  tu.diagnostics]))
     pprint(('nodes', get_info(tu.cursor)))
 
 if __name__ == '__main__':
Index: bindings/python/clang/cindex.py
===================================================================
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -44,6 +44,7 @@
 Most object information is exposed using properties, when the underlying API
 call is efficient.
 """
+from __future__ import absolute_import, division, print_function
 
 # TODO
 # ====
@@ -400,7 +401,7 @@
 
     @property
     def ranges(self):
-        class RangeIterator:
+        class RangeIterator(object):
             def __init__(self, diag):
                 self.diag = diag
 
@@ -416,7 +417,7 @@
 
     @property
     def fixits(self):
-        class FixItIterator:
+        class FixItIterator(object):
             def __init__(self, diag):
                 self.diag = diag
 
@@ -436,7 +437,7 @@
 
     @property
     def children(self):
-        class ChildDiagnosticsIterator:
+        class ChildDiagnosticsIterator(object):
             def __init__(self, diag):
                 self.diag_set = conf.lib.clang_getChildDiagnostics(diag)
 
@@ -556,7 +557,7 @@
 
         token_group = TokenGroup(tu, tokens_memory, tokens_count)
 
-        for i in xrange(0, count):
+        for i in range(0, count):
             token = Token()
             token.int_data = tokens_array[i].int_data
             token.ptr_data = tokens_array[i].ptr_data
@@ -2475,8 +2476,8 @@
             # 20: CompletionChunk.Kind("VerticalSpace")
 }
 
-class CompletionChunk:
-    class Kind:
+class CompletionChunk(object):
+    class Kind(object):
         def __init__(self, name):
             self.name = name
 
@@ -2563,7 +2564,7 @@
             20: CompletionChunk.Kind("VerticalSpace")}
 
 class CompletionString(ClangObject):
-    class Availability:
+    class Availability(object):
         def __init__(self, name):
             self.name = name
 
@@ -2656,7 +2657,7 @@
 
     @property
     def diagnostics(self):
-        class DiagnosticsItr:
+        class DiagnosticsItr(object):
             def __init__(self, ccr):
                 self.ccr= ccr
 
@@ -2958,7 +2959,7 @@
         """
         Return an iterable (and indexable) object containing the diagnostics.
         """
-        class DiagIterator:
+        class DiagIterator(object):
             def __init__(self, tu):
                 self.tu = tu
 
@@ -3190,7 +3191,7 @@
         Invariant : the first argument is the compiler executable
         """
         length = conf.lib.clang_CompileCommand_getNumArgs(self.cmd)
-        for i in xrange(length):
+        for i in range(length):
             yield conf.lib.clang_CompileCommand_getArg(self.cmd, i)
 
 class CompileCommands(object):
@@ -4090,7 +4091,7 @@
     for f in functionList:
         register(f)
 
-class Config:
+class Config(object):
     library_path = None
     library_file = None
     compatibility_check = True
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to