xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH] x86/gen-cpuid: Fix Py2/3 compatibility
@ 2020-02-25 16:57 Andrew Cooper
  2020-02-25 17:21 ` Wei Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cooper @ 2020-02-25 16:57 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monné

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>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/tools/gen-cpuid.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index 362cdb5306..71ea78f4eb 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -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, "")
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Xen-devel] [PATCH] x86/gen-cpuid: Fix Py2/3 compatibility
  2020-02-25 16:57 [Xen-devel] [PATCH] x86/gen-cpuid: Fix Py2/3 compatibility Andrew Cooper
@ 2020-02-25 17:21 ` Wei Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Liu @ 2020-02-25 17:21 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Xen-devel, Wei Liu, Jan Beulich, Roger Pau Monné

On Tue, Feb 25, 2020 at 04:57:48PM +0000, Andrew Cooper wrote:
> 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-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-25 17:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 16:57 [Xen-devel] [PATCH] x86/gen-cpuid: Fix Py2/3 compatibility Andrew Cooper
2020-02-25 17:21 ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).