On 22/02/18 05:52, Doug Goldstein wrote: > These changes should make it possible to support modern Pythons as well > as the oldest Python 2 still supported. > > Signed-off-by: Doug Goldstein <car...@cardoe.com>
To the overall effect, this is definitely a good thing. Some queries however... > --- > CC: Andrew Cooper <andrew.coop...@citrix.com> > CC: George Dunlap <george.dun...@eu.citrix.com> > CC: Ian Jackson <ian.jack...@eu.citrix.com> > CC: Jan Beulich <jbeul...@suse.com> > CC: Konrad Rzeszutek Wilk <konrad.w...@oracle.com> > CC: Stefano Stabellini <sstabell...@kernel.org> > CC: Tim Deegan <t...@xen.org> > CC: Wei Liu <wei.l...@citrix.com> > --- > xen/tools/compat-build-header.py | 2 +- > xen/tools/compat-build-source.py | 2 +- > xen/tools/gen-cpuid.py | 37 +++++++++++++++++++++++++++---------- > xen/tools/get-fields.sh | 2 +- > 4 files changed, 30 insertions(+), 13 deletions(-) > > diff --git a/xen/tools/compat-build-header.py > b/xen/tools/compat-build-header.py > index 32421b645b..546371225d 100755 > --- a/xen/tools/compat-build-header.py > +++ b/xen/tools/compat-build-header.py > @@ -23,4 +23,4 @@ pats = [ > for line in sys.stdin.readlines(): > for pat in pats: > line = re.subn(pat[0], pat[1], line)[0] > - print line.rstrip() > + sys.stdout.write(line.rstrip() + '\n') Is there anything wrong with print(line.rstrip()) which is the more common way of doing this? > diff --git a/xen/tools/compat-build-source.py > b/xen/tools/compat-build-source.py > index 595bc3ff58..8101290ebe 100755 > --- a/xen/tools/compat-build-source.py > +++ b/xen/tools/compat-build-source.py > @@ -26,4 +26,4 @@ for pat in pats: > for line in sys.stdin.readlines(): > for pat in pats: > line = re.sub(pat[0], pat[1], line) > - print line.rstrip() > + sys.stdout.write(line.rstrip() + '\n') > diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py > index 613b909c3d..d64f257816 100755 > --- a/xen/tools/gen-cpuid.py > +++ b/xen/tools/gen-cpuid.py > @@ -3,6 +3,13 @@ > > import sys, os, re > > +if (sys.version_info > (3, 0)): > + def long(x): > + return x Strictly speaking, return int(x), however... > + > + def xrange(x): > + return range(x) > + > class Fail(Exception): > pass > > @@ -98,13 +105,13 @@ def parse_definitions(state): > def featureset_to_uint32s(fs, nr): > """ Represent a featureset as a list of C-compatible uint32_t's """ > > - bitmap = 0L > + bitmap = long(0) > for f in fs: > - bitmap |= 1L << f > + bitmap |= long(1) << f Having tested this out, I think the L suffixes can just be dropped: Python 2.4.3 (#1, Sep 21 2011, 20:06:00) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> bitmap = 0 >>> type(bitmap) <type 'int'> >>> for x in xrange(80): bitmap |= 1 << x ... >>> type(bitmap) <type 'long'> >>> I don't recall why I wrote it like this, but I don't think its necessary. As a result, you shouldn't need to define long above. ~Andrew
_______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel