Repository: spack/spack

Issue:
"Specific Targets" does not work in Python 3
When Spack is run with Python 3, it fails to detect the specific target on my machine.

### Steps to reproduce the issue

```console
$ python2 $(which spack) arch
darwin-mojave-ivybridge
$ python3 $(which spack) arch
darwin-mojave-x86_64
```

### Information on your system

macOS 10.14.6, early 2013

Python 3.7.3

```console
$ sysctl -n machdep.cpu.vendor
GenuineIntel
$ sysctl -n machdep.cpu.features
FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC POPCNT AES PCID XSAVE OSXSAVE TSCTMR AVX1.0 RDRAND F16C
$ sysctl -n machdep.cpu.leaf7_features
RDWRFSGS SMEP ERMS MDCLEAR IBRS STIBP L1DF SSBD
$ sysctl -n machdep.cpu.model
58
$ sysctl -n machdep.cpu.brand_string
Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
```

@alalazo @tgamblin @becker33 


Discussion:
I'm getting closer to tracking this down. There appears to be a "try-except" that masks the following issue:
```
Traceback (most recent call last):
  File "/Users/Adam/spack/bin/spack", line 48, in <module>
    sys.exit(spack.main.main())
  File "/Users/Adam/spack/lib/spack/spack/main.py", line 713, in main
    if spack.config.get('config:debug'):
  File "/Users/Adam/spack/lib/spack/spack/config.py", line 628, in get
    return config.get(path, default, scope)
  File "/Users/Adam/spack/lib/spack/llnl/util/lang.py", line 558, in __getattr__
    return getattr(self.instance, name)
  File "/Users/Adam/spack/lib/spack/llnl/util/lang.py", line 554, in instance
    self._instance = self.factory()
  File "/Users/Adam/spack/lib/spack/spack/config.py", line 610, in _config
    _add_platform_scope(cfg, ConfigScope, name, path)
  File "/Users/Adam/spack/lib/spack/spack/config.py", line 563, in _add_platform_scope
    platform = spack.architecture.platform().name
  File "/Users/Adam/spack/lib/spack/llnl/util/lang.py", line 184, in _memoized_function
    func.cache[args] = func(*args)
  File "/Users/Adam/spack/lib/spack/spack/architecture.py", line 478, in platform
    return platform_cls()
  File "/Users/Adam/spack/lib/spack/spack/platforms/darwin.py", line 21, in __init__
    self.default = cpu.host().name
  File "/Users/Adam/spack/lib/spack/llnl/util/cpu/detect.py", line 153, in host
    info = raw_info_dictionary()
  File "/Users/Adam/spack/lib/spack/llnl/util/cpu/detect.py", line 127, in raw_info_dictionary
    info = factory()
  File "/Users/Adam/spack/lib/spack/llnl/util/cpu/detect.py", line 98, in sysctl
    ['sysctl', '-n', 'machdep.cpu.leaf7_features']
TypeError: can only concatenate str (not "bytes") to str
```

Resolving patch:
diff --git a/lib/spack/llnl/util/cpu/detect.py b/lib/spack/llnl/util/cpu/detect.py
--- a/lib/spack/llnl/util/cpu/detect.py
+++ b/lib/spack/llnl/util/cpu/detect.py
@@ -7,7 +7,7 @@
 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


Test patch: