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@durham.ac.uk>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
# 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):
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())