Skip to content

Commit c27f1da

Browse files
committed
Protect cpuinfo with try block for MacOSX
1 parent 5cbc1b3 commit c27f1da

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

numexpr/tests/test_numexpr.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,6 @@ def print_versions():
10111011
import platform
10121012

10131013
np_version = tuple( ver for ver in np.__version__.split('.') )
1014-
cpu_info = cpu.info[0]
10151014

10161015
if minimum_numpy_version < np_version:
10171016
print('*Warning*: NumPy version is lower than recommended: %s < %s' % \
@@ -1022,9 +1021,15 @@ def print_versions():
10221021
print('Python version: %s' % sys.version)
10231022
(sysname, nodename, release, os_version, machine, processor) = platform.uname()
10241023
print('Platform: %s-%s-%s' % (sys.platform, machine, os_version))
1025-
print('CPU vendor: %s' % cpu_info.get('VendorIdentifier', ''))
1026-
print('CPU model: %s' % cpu_info.get('ProcessorNameString', ''))
1027-
print('CPU clock speed: %s MHz' % cpu_info.get('~MHz',''))
1024+
try:
1025+
# cpuinfo doesn't work on OSX well it seems, so protect these outputs
1026+
# with a try block
1027+
cpu_info = cpu.info[0]
1028+
print('CPU vendor: %s' % cpu_info.get('VendorIdentifier', ''))
1029+
print('CPU model: %s' % cpu_info.get('ProcessorNameString', ''))
1030+
print('CPU clock speed: %s MHz' % cpu_info.get('~MHz',''))
1031+
except KeyError:
1032+
pass
10281033
print('VML available? %s' % use_vml)
10291034
if use_vml:
10301035
print('VML/MKL version: %s' % numexpr.get_vml_version())

0 commit comments

Comments
 (0)