From: Wei Liu <wei.liu2@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
m.a.young@durham.ac.uk
Subject: [PATCH 3/4] pygrub: decode string in Python 3
Date: Mon, 1 Apr 2019 11:32:37 +0100 [thread overview]
Message-ID: <20190401103238.15649-4-wei.liu2@citrix.com> (raw)
In-Reply-To: <20190401103238.15649-1-wei.liu2@citrix.com>
String is unicode in 3 but bytes in 2. We need to call decode function
when using Python 3.
Reported-by: M A Young <m.a.young@durham.ac.uk>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
tools/pygrub/src/pygrub | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
index dbdce315c6..23312eae76 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):
--
2.20.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-04-01 10:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-01 10:32 [PATCH 0/4] More python fixes Wei Liu
2019-04-01 10:32 ` [PATCH 1/4] pygrub: fix message in grub parser Wei Liu
2019-04-01 16:16 ` Andrew Cooper
2019-04-01 10:32 ` [PATCH 2/4] pygrub/grub: always use integer for default entry Wei Liu
2019-04-01 16:20 ` Andrew Cooper
2019-04-01 10:32 ` Wei Liu [this message]
2019-04-01 16:21 ` [PATCH 3/4] pygrub: decode string in Python 3 Andrew Cooper
2019-04-01 10:32 ` [PATCH 4/4] tools/ocaml: make python scripts 2 and 3 compatible Wei Liu
2019-04-01 16:22 ` Andrew Cooper
2019-04-01 16:24 ` Christian Lindig
2019-04-01 20:36 ` [PATCH 0/4] More python fixes YOUNG, MICHAEL A.
2019-04-02 8:18 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190401103238.15649-4-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=m.a.young@durham.ac.uk \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).