diff --git a/devlib/instrument/acmecape.py b/devlib/instrument/acmecape.py index 0d843a4..cc47d6d 100644 --- a/devlib/instrument/acmecape.py +++ b/devlib/instrument/acmecape.py @@ -97,7 +97,7 @@ class AcmeCapeInstrument(Instrument): raise HostError(msg.format(output)) if self.process.returncode != 15: # iio-capture exits with 15 when killed if sys.version_info[0] == 3: - output += self.process.stdout.read().decode(sys.stdout.encoding) + output += self.process.stdout.read().decode(sys.stdout.encoding, 'replace') else: output += self.process.stdout.read() self.logger.info('ACME instrument encountered an error, ' diff --git a/devlib/instrument/energy_probe.py b/devlib/instrument/energy_probe.py index b832d71..a817369 100644 --- a/devlib/instrument/energy_probe.py +++ b/devlib/instrument/energy_probe.py @@ -82,8 +82,8 @@ class EnergyProbeInstrument(Instrument): if self.process.returncode is not None: stdout, stderr = self.process.communicate() if sys.version_info[0] == 3: - stdout = stdout.decode(sys.stdout.encoding) - stderr = stderr.decode(sys.stdout.encoding) + stdout = stdout.decode(sys.stdout.encoding, 'replace') + stderr = stderr.decode(sys.stdout.encoding, 'replace') raise HostError( 'Energy Probe: Caiman exited unexpectedly with exit code {}.\n' 'stdout:\n{}\nstderr:\n{}'.format(self.process.returncode, diff --git a/devlib/trace/ftrace.py b/devlib/trace/ftrace.py index bfa3b5b..8e62ffa 100644 --- a/devlib/trace/ftrace.py +++ b/devlib/trace/ftrace.py @@ -278,7 +278,7 @@ class FtraceCollector(TraceCollector): process = subprocess.Popen(command, stderr=subprocess.PIPE, shell=True) _, error = process.communicate() if sys.version_info[0] == 3: - error = error.decode(sys.stdout.encoding) + error = error.decode(sys.stdout.encoding, 'replace') if process.returncode: raise TargetError('trace-cmd returned non-zero exit code {}'.format(process.returncode)) if error: diff --git a/devlib/utils/android.py b/devlib/utils/android.py index 0a9dfeb..4b43808 100755 --- a/devlib/utils/android.py +++ b/devlib/utils/android.py @@ -153,7 +153,7 @@ class ApkInfo(object): try: output = subprocess.check_output(command, stderr=subprocess.STDOUT) if sys.version_info[0] == 3: - output = output.decode(sys.stdout.encoding) + output = output.decode(sys.stdout.encoding, 'replace') except subprocess.CalledProcessError as e: raise HostError('Error parsing APK file {}. `aapt` says:\n{}' .format(apk_path, e.output)) diff --git a/devlib/utils/ssh.py b/devlib/utils/ssh.py index 3243708..9daa380 100644 --- a/devlib/utils/ssh.py +++ b/devlib/utils/ssh.py @@ -265,7 +265,7 @@ class SshConnection(object): # the regex removes line breaks potential introduced when writing # command to shell. if sys.version_info[0] == 3: - output = process_backspaces(self.conn.before.decode(sys.stdout.encoding)) + output = process_backspaces(self.conn.before.decode(sys.stdout.encoding, 'replace')) else: output = process_backspaces(self.conn.before) output = re.sub(r'\r([^\n])', r'\1', output) diff --git a/devlib/utils/version.py b/devlib/utils/version.py index de37dce..1669a6e 100644 --- a/devlib/utils/version.py +++ b/devlib/utils/version.py @@ -10,6 +10,6 @@ def get_commit(): if p.returncode: return None if sys.version_info[0] == 3: - return std[:8].decode(sys.stdout.encoding) + return std[:8].decode(sys.stdout.encoding, 'replace') else: return std[:8]