From c3b599167f9dcf8b8b6e493c8e51ebaacf6b9802 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 10 Feb 2013 15:12:21 +0200 Subject: [PATCH] Guard against invalid compiler command line. --- environment.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/environment.py b/environment.py index 637b280da..6dd775b81 100755 --- a/environment.py +++ b/environment.py @@ -222,7 +222,10 @@ class Environment(): def detect_c_compiler(self): exelist = self.get_c_compiler_exelist() - p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE) + try: + p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE) + except OSError: + raise EnvironmentException('Could not execute C compiler "%s"' % ' '.join(exelist)) out = p.communicate()[0] out = out.decode() if (out.startswith('cc ') or out.startswith('gcc')) and \ @@ -241,7 +244,10 @@ class Environment(): def detect_cxx_compiler(self): exelist = self.get_cxx_compiler_exelist() - p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE) + try: + p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE) + except OSError: + raise EnvironmentException('Could not execute C++ compiler "%s"' % ' '.join(exelist)) out = p.communicate()[0] out = out.decode() if (out.startswith('c++ ') or out.startswith('g++')) and \