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