|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] python3 issues
On Mon, Mar 25, 2019 at 10:20:05PM +0000, YOUNG, MICHAEL A. wrote:
> I have been testing the python3 changes committed to xen and found a few
> issues. There are a couple of ocaml python build scripts that don't work
> for me with python3, and I needed a few fixes to get pygrub to work,
> mostly due to the change from strings to bytes. I am attaching the patch I
> put together in testing to get these things to work to illustrate where
> the problems are and in case it is useful to others, though I believe at
> least some of it isn't compatible with python2.
Most Python code can be easily made compatible with both Python 2 and
Python 3 with the right constructs.
> --- xen-4.12.0-rc5/tools/ocaml/libs/xentoollog/genlevels.py.orig
> 2019-03-06 14:42:49.000000000 +0000
> +++ xen-4.12.0-rc5/tools/ocaml/libs/xentoollog/genlevels.py 2019-03-13
> 21:33:59.805930989 +0000
> @@ -86,14 +87,14 @@
> def autogen_header(open_comment, close_comment):
> s = open_comment + " AUTO-GENERATED FILE DO NOT EDIT " + close_comment +
> "\n"
> s += open_comment + " autogenerated by \n"
> - s += reduce(lambda x,y: x + " ", range(len(open_comment + " ")), "")
> + s += reduce(lambda x,y: x + " ", list(range(len(open_comment + " "))),
> "")
> s += "%s" % " ".join(sys.argv)
> s += "\n " + close_comment + "\n\n"
> return s
>
> if __name__ == '__main__':
> if len(sys.argv) < 3:
> - print >>sys.stderr, "Usage: genlevels.py <mli> <ml> <c-inc>"
> + print("Usage: genlevels.py <mli> <ml> <c-inc>", file=sys.stderr)
> sys.exit(1)
>
> levels, olevels = read_levels()
The print() function notation is required for Python 3, but has a bit of
trouble with Python 2. Python 2 though does have support. At the top of
the relevant files add "from __future__ import print_function" and the
print() will work in Python 2. I'm unsure of the status of the other
constructs in this patch.
--
(\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/)
\BS ( | ehem+sigmsg@xxxxxxx PGP 87145445 | ) /
\_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |