|
[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.
My fault. Somehow all my local testing and project's CIs failed to catch
these files.
Thanks for fixing these. I will turn it into a proper patch, put your
SoB there and submit it.
>
> Michael Young
> --- 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
> @@ -1,6 +1,7 @@
> #!/usr/bin/python
>
> import sys
> +from functools import reduce
We should have from __future__ import print_function here to be python2
compatible.
>
> def read_levels():
> f = open('../../../libs/toollog/include/xentoollog.h', 'r')
> @@ -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 + " "))),
> "")
I don't think list is required here. reduce should work with generator
just fine.
> 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()
> --- xen-4.12.0-rc5/tools/ocaml/libs/xl/genwrap.py.orig 2019-03-06
> 14:42:49.000000000 +0000
> +++ xen-4.12.0-rc5/tools/ocaml/libs/xl/genwrap.py 2019-03-13
> 21:34:00.674962832 +0000
> @@ -3,6 +3,7 @@
> import sys,os
>
> import idl
> +from functools import reduce
Same here as above.
> if ty.init_fn is not None:
> --- xen-4.12.0-rc6/tools/pygrub/src/GrubConf.py.orig 2019-03-24
> 22:44:05.502581989 +0000
> +++ xen-4.12.0-rc6/tools/pygrub/src/GrubConf.py 2019-03-24
> 22:49:14.025934786 +0000
> @@ -230,10 +230,10 @@
> def _get_default(self):
> return self._default
> def _set_default(self, val):
> - if val == "saved":
> + if val == "saved" or not val.isdecimal():
> self._default = 0
> else:
> - self._default = val
> + self._default = int(val)
>
> if self._default < 0:
> raise ValueError("default must be positive number")
> --- xen-4.12.0-rc6/tools/pygrub/src/pygrub.orig 2019-03-24
> 22:44:05.503582025 +0000
> +++ xen-4.12.0-rc6/tools/pygrub/src/pygrub 2019-03-24 22:48:24.446113809
> +0000
> @@ -457,7 +457,7 @@
> # limit read size to avoid pathological cases
> buf = f.read(FS_READ_MAX)
> del f
> - self.cf.parse(buf)
> + self.cf.parse(buf.decode())
Hmm... This could be a bit problematic for 2 compatibility. I will need
some time to check the documents.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |