diff --git a/testing/xpcshell/runxpcshelltests.py b/testing/xpcshell/runxpcshelltests.py index 0774a76f4bf7..e5c363862e7b 100755 --- a/testing/xpcshell/runxpcshelltests.py +++ b/testing/xpcshell/runxpcshelltests.py @@ -649,9 +649,13 @@ class XPCShellTestThread(Thread): self.has_failure_output = True def fix_text_output(self, line): + line = cleanup_encoding(line) if self.stack_fixer_function is not None: line = self.stack_fixer_function(line) - return cleanup_encoding(line) + + if isinstance(line, bytes): + line = line.decode("utf-8") + return line def log_line(self, line): """Log a line of output (either a parser json object or text output from diff --git a/tools/rb/fix_stacks.py b/tools/rb/fix_stacks.py index a411675d530e..bd48fc9e0e53 100755 --- a/tools/rb/fix_stacks.py +++ b/tools/rb/fix_stacks.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # vim:sw=4:ts=4:et: # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -74,11 +74,7 @@ def fixSymbols( line, jsonMode=False, slowWarning=False, breakpadSymsDir=None, hide_errors=False ): - if isinstance(line, bytes): - line_str = line.decode("utf-8") - else: - line_str = line - + line_str = line.decode("utf-8") if isinstance(line, bytes) else line if line_re.search(line_str) is None: return line @@ -97,7 +93,10 @@ def fixSymbols( out = fix_stacks.stdout.readline() if is_missing_newline: out = out[:-1] - return bytes(out, "utf-8") + + if not isinstance(out, bytes): + out = out.encode("utf-8") + return out if __name__ == "__main__":