From 97274621a557214f5bba41fda57efcce71e06b00 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 15 Feb 2020 23:24:16 +0530 Subject: [PATCH] Popen_safe: Always re-setup the console colors --- mesonbuild/mesonlib.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index f3c07591f..e09d123b9 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -1084,10 +1084,15 @@ def Popen_safe(args: T.List[str], write: T.Optional[str] = None, if 'stdin' not in kwargs: kwargs['stdin'] = subprocess.DEVNULL if sys.version_info < (3, 6) or not sys.stdout.encoding or encoding.upper() != 'UTF-8': - return Popen_safe_legacy(args, write=write, stdout=stdout, stderr=stderr, **kwargs) - p = subprocess.Popen(args, universal_newlines=True, close_fds=False, - stdout=stdout, stderr=stderr, **kwargs) - o, e = p.communicate(write) + p, o, e = Popen_safe_legacy(args, write=write, stdout=stdout, stderr=stderr, **kwargs) + else: + p = subprocess.Popen(args, universal_newlines=True, close_fds=False, + stdout=stdout, stderr=stderr, **kwargs) + o, e = p.communicate(write) + # Sometimes the command that we run will call another command which will be + # without the above stdin workaround, so set the console mode again just in + # case. + mlog.setup_console() return p, o, e def Popen_safe_legacy(args: T.List[str], write: T.Optional[str] = None,