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.
This commit is contained in:
Adam J. Stewart 2019-09-24 11:47:54 -05:00 committed by Todd Gamblin
parent 6cd5edacca
commit 065cbe89fe

View file

@ -7,7 +7,7 @@
import platform import platform
import re import re
import subprocess import subprocess
import sys import warnings
import six import six
@ -76,11 +76,8 @@ def proc_cpuinfo():
def check_output(args): def check_output(args):
if sys.version_info[:2] == (2, 6): output = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0]
return subprocess.run( return six.text_type(output.decode('utf-8'))
args, check=True, stdout=subprocess.PIPE).stdout # nopyqver
else:
return subprocess.check_output(args) # nopyqver
@info_dict(operating_system='Darwin') @info_dict(operating_system='Darwin')
@ -126,8 +123,8 @@ def raw_info_dictionary():
for factory in info_factory[platform.system()]: for factory in info_factory[platform.system()]:
try: try:
info = factory() info = factory()
except Exception: except Exception as e:
pass warnings.warn(str(e))
if info: if info:
break break