From 01bb7564847dded2c9de756363c2ff97f0a02a8e Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 16 May 2023 11:08:02 -0400 Subject: [PATCH] rust: Use Popen_safe() for sanity checks --- mesonbuild/compilers/rust.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index a63e6643e..abdc2b354 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -80,16 +80,7 @@ class RustCompiler(Compiler): ''')) cmdlist = self.exelist + ['-o', output_name, source_name] - pc = subprocess.Popen(cmdlist, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - cwd=work_dir) - _stdo, _stde = pc.communicate() - assert isinstance(_stdo, bytes) - assert isinstance(_stde, bytes) - stdo = _stdo.decode('utf-8', errors='replace') - stde = _stde.decode('utf-8', errors='replace') - + pc, stdo, stde = Popen_safe(cmdlist, cwd=work_dir) mlog.debug('Sanity check compiler command line:', join_args(cmdlist)) mlog.debug('Sanity check compile stdout:') mlog.debug(stdo) @@ -108,7 +99,7 @@ class RustCompiler(Compiler): pe = subprocess.Popen(cmdlist, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) pe.wait() if pe.returncode != 0: - raise EnvironmentException('Executables created by Rust compiler %s are not runnable.' % self.name_string()) + raise EnvironmentException(f'Executables created by Rust compiler {self.name_string()} are not runnable.') def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]: return ['--dep-info', outfile]