When reading stdin python 3.x will give us byte arrays, and when writing stdout or stderr it will expect byte arrays. In order to insulate the rest of the code from this difference, call encode or decode at appropriate points when reading or writing stdio files. This works fine on python 2.x too.
Signed-off-by: Paul Burton <paul.bur...@imgtec.com> --- test/py/multiplexed_log.py | 4 ++-- test/py/tests/test_ut.py | 2 +- test/py/u_boot_spawn.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py index bf926c3e77..21bdcb7309 100644 --- a/test/py/multiplexed_log.py +++ b/test/py/multiplexed_log.py @@ -140,11 +140,11 @@ class RunAndLog(object): if stdout: if stderr: output += 'stdout:\n' - output += stdout + output += stdout.decode('utf8') if stderr: if stdout: output += 'stderr:\n' - output += stderr + output += stderr.decode('utf8') exit_status = p.returncode exception = None except subprocess.CalledProcessError as cpe: diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 5c25a2d465..1f40e2c2d0 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -14,7 +14,7 @@ def test_ut_dm_init(u_boot_console): data = 'this is a test' data += '\x00' * ((4 * 1024 * 1024) - len(data)) with open(fn, 'wb') as fh: - fh.write(data) + fh.write(data.encode('utf-8')) fn = u_boot_console.config.source_dir + '/spi.bin' if not os.path.exists(fn): diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py index 638c5dd31d..751302a529 100644 --- a/test/py/u_boot_spawn.py +++ b/test/py/u_boot_spawn.py @@ -114,7 +114,7 @@ class Spawn(object): Nothing. """ - os.write(self.fd, data) + os.write(self.fd, data.encode('utf8')) def expect(self, patterns): """Wait for the sub-process to emit specific data. @@ -172,7 +172,7 @@ class Spawn(object): events = self.poll.poll(poll_maxwait) if not events: raise Timeout() - c = os.read(self.fd, 1024) + c = os.read(self.fd, 1024).decode('utf8') if not c: raise EOFError() if self.logfile_read: -- 2.14.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot