Bug 1696531 - Keep Python 2 compatibility in tools/rb/fix_stacks.py for now, r=bhearsum

This file is also used by some browser-chrome tests which are still Python 2
for now. So let's not drop PY2 compat just yet.

Depends on D109728

Differential Revision: https://phabricator.services.mozilla.com/D111728
This commit is contained in:
Andrew Halberstadt 2021-04-14 13:54:27 +00:00
Родитель e311833cb9
Коммит cc560a87f0
2 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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__":