From 065cbe89fed448fcc64593f679867a7a7ad3cbd1 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 24 Sep 2019 11:47:54 -0500 Subject: Fix "specific target" detection in Python 3 (#12906) The output of subprocess.check_output is a byte string in Python 3. This causes dictionary lookup to fail later on. A try-except around this function prevented this error from being noticed. Removed this so that more errors can propagate out. --- lib/spack/llnl/util/cpu/detect.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/spack/llnl/util/cpu/detect.py b/lib/spack/llnl/util/cpu/detect.py index 40a427a5da..7744d5acd2 100644 --- a/lib/spack/llnl/util/cpu/detect.py +++ b/lib/spack/llnl/util/cpu/detect.py @@ -7,7 +7,7 @@ import functools import platform import re import subprocess -import sys +import warnings import six @@ -76,11 +76,8 @@ def proc_cpuinfo(): def check_output(args): - if sys.version_info[:2] == (2, 6): - return subprocess.run( - args, check=True, stdout=subprocess.PIPE).stdout # nopyqver - else: - return subprocess.check_output(args) # nopyqver + output = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0] + return six.text_type(output.decode('utf-8')) @info_dict(operating_system='Darwin') @@ -126,8 +123,8 @@ def raw_info_dictionary(): for factory in info_factory[platform.system()]: try: info = factory() - except Exception: - pass + except Exception as e: + warnings.warn(str(e)) if info: break -- cgit v1.2.3-70-g09d2