aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-02-15 23:24:16 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2020-02-16 00:26:08 +0530
commit97274621a557214f5bba41fda57efcce71e06b00 (patch)
tree4d9dd998cdf82d1c1d028cb4758a1c3f5dafebd5
parentc05b72512299f5aaf33c189a8ff959668f19574f (diff)
downloadmeson-97274621a557214f5bba41fda57efcce71e06b00.zip
meson-97274621a557214f5bba41fda57efcce71e06b00.tar.gz
meson-97274621a557214f5bba41fda57efcce71e06b00.tar.bz2
Popen_safe: Always re-setup the console colors
-rw-r--r--mesonbuild/mesonlib.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index f3c0759..e09d123 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,