From c99fc40bb7bacfed4ea79b4b83bec46fdc5018f3 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 24 Mar 2024 00:01:38 -0400 Subject: compilers: fix crash when compiler check returns None output Popen_safe_logged has a small inefficiency. It evaluates the stripped version of stdout/stderr before checking if it exists, for logging purposes. This would sometimes crash, if it was None instead of ''. Fixes #12979 --- mesonbuild/utils/universal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index edb309f0d..324fb94b0 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -1587,7 +1587,7 @@ def Popen_safe_logged(args: T.List[str], msg: str = 'Called', **kwargs: T.Any) - mlog.debug(f'{msg}: `{join_args(args)}` -> {excp}') raise - rc, out, err = p.returncode, o.strip(), e.strip() + rc, out, err = p.returncode, o.strip() if o else None, e.strip() if e else None mlog.debug('-----------') mlog.debug(f'{msg}: `{join_args(args)}` -> {rc}') if out: -- cgit v1.2.3