[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] pygrub: encode / decode string in Python 3
commit ff915c8cacc264ae1380d51fea07267b8308d7ba Author: Wei Liu <wei.liu2@xxxxxxxxxx> AuthorDate: Mon Apr 1 11:32:37 2019 +0100 Commit: Wei Liu <wei.liu2@xxxxxxxxxx> CommitDate: Tue Apr 2 09:50:41 2019 +0100 pygrub: encode / decode string in Python 3 String is unicode in 3 but bytes in 2. We need to call encode / decode function when using Python 3. Reported-by: M A Young <m.a.young@xxxxxxxxxxxx> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- tools/pygrub/src/pygrub | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub index dbdce315c6..ce7ab0eb8c 100755 --- a/tools/pygrub/src/pygrub +++ b/tools/pygrub/src/pygrub @@ -457,7 +457,10 @@ class Grub: # limit read size to avoid pathological cases buf = f.read(FS_READ_MAX) del f - self.cf.parse(buf) + if sys.version_info[0] < 3: + self.cf.parse(buf) + else: + self.cf.parse(buf.decode()) def image_index(self): if isinstance(self.cf.default, int): @@ -960,5 +963,8 @@ if __name__ == "__main__": 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()) -- generated by git-patchbot for /home/xen/git/xen.git#staging _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |