@@ -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:
@@ -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):
@@ -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:
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.burton@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(-)