From 17233f2dd298a1ed6933e45870c3cb6878456cef Mon Sep 17 00:00:00 2001 From: marmeladema Date: Mon, 9 Dec 2019 21:17:34 +0000 Subject: [PATCH] Write subprocess stdout/stderr logs to raw stdout buffer when using Python3 --- python/mach_bootstrap.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/python/mach_bootstrap.py b/python/mach_bootstrap.py index 5dd1077c9235..049dff4b7e73 100644 --- a/python/mach_bootstrap.py +++ b/python/mach_bootstrap.py @@ -104,13 +104,22 @@ def _process_exec(args): if process.returncode: print('"%s" failed with error code %d:' % ('" "'.join(args), process.returncode)) + if sys.version_info >= (3, 0): + stdout = sys.stdout.buffer + else: + stdout = sys.stdout + print('Output:') out.seek(0) - shutil.copyfileobj(out, sys.stdout) + stdout.flush() + shutil.copyfileobj(out, stdout) + stdout.flush() print('Error:') err.seek(0) - shutil.copyfileobj(err, sys.stdout) + stdout.flush() + shutil.copyfileobj(err, stdout) + stdout.flush() sys.exit(1)