зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1603634 - check if line is a decodable type r=aki,marco
Changes: Due to changes in `subprocess.Popen` return values in python3, it makes sense to check first if the line is a decodable type prior to attempting such action. This change will resolve the following failure when tests are run in python3: ``` ====================================================================== 2) ERROR: test_get_output_from_command (test_base_script.TestHelperFunctions) ---------------------------------------------------------------------- Traceback (most recent call last): test/test_base_script.py line 370 in test_get_output_from_command contents = self.s.get_output_from_command(["bash", "-c", "cat %s" % self.temp_file]) mozharness/base/script.py line 1658 in get_output_from_command line = line.decode("utf-8") AttributeError: 'str' object has no attribute 'decode' -------------------- >> begin captured logging << -------------------- root: INFO: ConsoleLogger online at 20191215 00:24:05Z in /Users/egao/mozilla-central/testing/mozharness root: INFO: Run as .tox/py35-hg4.3/bin/nosetests -v --with-xunit --rednose --force-color root: INFO: Getting output from command: ['bash', '-c', 'cat test_dir/mozilla'] root: INFO: Copy/paste: bash -c "cat test_dir/mozilla" root: INFO: Reading from file tmpfile_stdout root: INFO: Output received: --------------------- >> end captured logging << --------------------- ``` Differential Revision: https://phabricator.services.mozilla.com/D57225 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b882153384
Коммит
02bff2aeae
|
@ -36,6 +36,8 @@ import zlib
|
|||
from contextlib import contextmanager
|
||||
from io import BytesIO
|
||||
|
||||
from six import binary_type
|
||||
|
||||
from mozprocess import ProcessHandler
|
||||
|
||||
import mozinfo
|
||||
|
@ -1655,7 +1657,8 @@ class ScriptMixin(PlatformMixin):
|
|||
for line in output_lines:
|
||||
if not line or line.isspace():
|
||||
continue
|
||||
line = line.decode("utf-8")
|
||||
if isinstance(line, binary_type):
|
||||
line = line.decode("utf-8")
|
||||
self.log(' %s' % line, level=log_level)
|
||||
output = '\n'.join(output_lines)
|
||||
if os.path.exists(tmp_stderr_filename) and os.path.getsize(tmp_stderr_filename):
|
||||
|
@ -1667,7 +1670,8 @@ class ScriptMixin(PlatformMixin):
|
|||
for line in errors.rstrip().splitlines():
|
||||
if not line or line.isspace():
|
||||
continue
|
||||
line = line.decode("utf-8")
|
||||
if isinstance(line, binary_type):
|
||||
line = line.decode("utf-8")
|
||||
self.log(' %s' % line, level=return_level)
|
||||
elif p.returncode not in success_codes and not ignore_errors:
|
||||
return_level = ERROR
|
||||
|
|
Загрузка…
Ссылка в новой задаче