From 4404d9062c40bf84d261d70f3e439e4ad77fdcc6 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Mon, 6 Feb 2012 02:13:25 +0100 Subject: [PATCH] cleanup --- waflib/Tools/c_config.py | 6 +++--- waflib/Tools/fc_config.py | 15 +++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/waflib/Tools/c_config.py b/waflib/Tools/c_config.py index 89dc83d0..fffd3cc0 100644 --- a/waflib/Tools/c_config.py +++ b/waflib/Tools/c_config.py @@ -1014,11 +1014,11 @@ def get_cc_version(conf, cc, gcc=False, icc=False): p = Utils.subprocess.Popen(cmd, stdin=Utils.subprocess.PIPE, stdout=Utils.subprocess.PIPE, stderr=Utils.subprocess.PIPE, env=env) p.stdin.write('\n'.encode()) out = p.communicate()[0] - except: + except Exception: conf.fatal('Could not determine the compiler version %r' % cmd) if not isinstance(out, str): - out = out.decode(sys.stdout.encoding) + out = out.decode(sys.stdout.encoding or 'iso8859-1') if gcc: if out.find('__INTEL_COMPILER') >= 0: @@ -1031,7 +1031,7 @@ def get_cc_version(conf, cc, gcc=False, icc=False): k = {} if icc or gcc: - out = out.split('\n') + out = out.splitlines() for line in out: lst = shlex.split(line) if len(lst)>2: diff --git a/waflib/Tools/fc_config.py b/waflib/Tools/fc_config.py index 7e367c8b..87f389fb 100644 --- a/waflib/Tools/fc_config.py +++ b/waflib/Tools/fc_config.py @@ -336,15 +336,14 @@ def getoutput(conf, cmd, stdin=False): p = Utils.subprocess.Popen(cmd, stdin=stdin, stdout=Utils.subprocess.PIPE, stderr=Utils.subprocess.PIPE, env=env) if stdin: p.stdin.write('\n'.encode()) - stdout, stderr = p.communicate() - except: + out, err = p.communicate() + except Exception: conf.fatal('could not determine the compiler version %r' % cmd) - else: - if not isinstance(stdout, str): - stdout = stdout.decode(sys.stdout.encoding) - if not isinstance(stderr, str): - stderr = stderr.decode(sys.stdout.encoding) - return stdout, stderr + if not isinstance(out, str): + out = out.decode(sys.stdout.encoding or 'iso8859-1') + if not isinstance(err, str): + err = err.decode(sys.stdout.encoding or 'iso8859-1') + return (out, err) # ------------------------------------------------------------------------