diff mbox series

[3/4] pygrub: decode string in Python 3

Message ID 20190401103238.15649-4-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show
Series More python fixes | expand

Commit Message

Wei Liu April 1, 2019, 10:32 a.m. UTC
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(-)

Comments

Andrew Cooper April 1, 2019, 4:21 p.m. UTC | #1
On 01/04/2019 11:32, Wei Liu wrote:
> 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>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox series

Patch

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):