[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 0/4] More python fixes



On Mon, Apr 01, 2019 at 08:36:44PM +0000, YOUNG, MICHAEL A. wrote:
> On Mon, 1 Apr 2019, Wei Liu wrote:
> 
> > Wei Liu (4):
> >  pygrub: fix message in grub parser
> >  pygrub/grub: always use integer for default entry
> >  pygrub: decode string in Python 3
> >  tools/ocaml: make python scripts 2 and 3 compatible
> >
> > tools/ocaml/libs/xentoollog/genlevels.py |  5 ++++-
> > tools/ocaml/libs/xl/genwrap.py           | 17 ++++++++++-------
> > tools/pygrub/src/GrubConf.py             |  8 ++++++--
> > tools/pygrub/src/pygrub                  |  5 ++++-
> > 4 files changed, 24 insertions(+), 11 deletions(-)
> 
> There is a bit missing compared to my original patch which is to convert 
> the string back to bytes for the final write out and avoid the error
> 
> Traceback (most recent call last):
>    File "/tmp/xencode/usr/libexec/xen/bin/pygrub", line 967, in <module>
>      os.write(fd, ostring)
> TypeError: a bytes-like object is required, not 'str'
> 
> The attached patch works for me in a quick test on python3 though I 
> haven't tested it on python2 yet.
> 
>       Michael Young

> --- xen-4.12.0/tools/pygrub/src/pygrub.orig   2019-04-01 21:25:33.206405995 
> +0100
> +++ xen-4.12.0/tools/pygrub/src/pygrub        2019-04-01 21:27:36.179929105 
> +0100
> @@ -963,5 +963,8 @@
>          ostring = format_simple(bootcfg["kernel"], bootcfg["ramdisk"], args, 
> "\0")
>  
>      sys.stdout.flush()
> -    os.write(fd, ostring)
> +    if sys.version_info[0] < 3:
> +        os.write(fd, ostring)
> +    else:
> +        os.write(fd, ostring.encode())
>      


This should work. I will fold this in to the pygrub patch.

Thanks for spotting my mistake.

Wei.

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.