]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
x86/gen-cpuid: Fix Py2/3 compatibility
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 25 Feb 2020 15:43:55 +0000 (15:43 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 26 Feb 2020 12:13:10 +0000 (12:13 +0000)
There is a fencepost error on the sys.version_info check which will break on
Python 3.0.  Reverse the logic to make py2 compatible with py3 (rather than
py3 compatible with py2) which will be more natural to follow as py2 usage
reduces.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wl@xen.org>
xen/tools/gen-cpuid.py

index 362cdb530680fc5532a8b84f44fcca2986906011..71ea78f4ebe37328fb742448705f6c75fbb65049 100755 (executable)
@@ -3,9 +3,8 @@
 
 import sys, os, re
 
-if (sys.version_info > (3, 0)):
-    def xrange(x):
-        return range(x)
+if sys.version_info < (3, 0):
+    range = xrange
 
 class Fail(Exception):
     pass
@@ -330,10 +329,10 @@ def crunch_numbers(state):
         state.deep_deps[k] = featureset_to_uint32s(v, nr_entries)
 
     # Calculate the bitfield name declarations
-    for word in xrange(nr_entries):
+    for word in range(nr_entries):
 
         names = []
-        for bit in xrange(32):
+        for bit in range(32):
 
             name = state.names.get(word * 32 + bit, "")