[PATCH] D55193: Python2/3 compatibility - ranges

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 18 00:27:19 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL349448: Portable Python script across Python version (authored by serge_sans_paille, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55193?vs=176567&id=178606#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55193

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/utils/ABITest/Enumeration.py
  cfe/trunk/utils/ABITest/TypeGen.py
  cfe/trunk/utils/modfuzz.py


Index: cfe/trunk/utils/modfuzz.py
===================================================================
--- cfe/trunk/utils/modfuzz.py
+++ cfe/trunk/utils/modfuzz.py
@@ -106,7 +106,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: cfe/trunk/utils/ABITest/TypeGen.py
===================================================================
--- cfe/trunk/utils/ABITest/TypeGen.py
+++ cfe/trunk/utils/ABITest/TypeGen.py
@@ -242,7 +242,7 @@
     # combinations, selections of a sequence
     if k==0: yield []
     else:
-        for i in xrange(len(values)-k+1):
+        for i in range(len(values)-k+1):
             for cc in combinations(values[i+1:],k-1):
                 yield [values[i]]+cc
 
Index: cfe/trunk/utils/ABITest/Enumeration.py
===================================================================
--- cfe/trunk/utils/ABITest/Enumeration.py
+++ cfe/trunk/utils/ABITest/Enumeration.py
@@ -199,7 +199,7 @@
         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):
Index: cfe/trunk/bindings/python/clang/cindex.py
===================================================================
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -109,8 +109,6 @@
             return x
         return x.encode('utf8')
 
-    xrange = range
-
 elif sys.version_info[0] == 2:
     # Python 2 strings are utf8 byte strings, no translation is needed for
     # C-interop.
@@ -556,7 +554,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
@@ -3190,7 +3188,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):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55193.178606.patch
Type: text/x-patch
Size: 2447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181218/86f09593/attachment.bin>


More information about the llvm-commits mailing list