1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 02:40:50 +01:00

utils/misc: check_output: handle unset sys encoding

Default to assuming 'utf-8' encoding for environments where
sys.stdout.encoding is not set.
This commit is contained in:
Sergei Trofimov 2018-07-18 16:49:36 +01:00 committed by Marc Bonnici
parent e8a03e00f3
commit df61b2a269

View File

@ -183,9 +183,9 @@ def check_output(command, timeout=None, ignore=None, inputtext=None,
output, error = process.communicate(inputtext)
if sys.version_info[0] == 3:
# Currently errors=replace is needed as 0x8c throws an error
output = output.decode(sys.stdout.encoding, "replace")
output = output.decode(sys.stdout.encoding or 'utf-8', "replace")
if error:
error = error.decode(sys.stderr.encoding, "replace")
error = error.decode(sys.stderr.encoding or 'utf-8', "replace")
finally:
if timeout:
timer.cancel()