Skip to content

Commit 88c01b8

Browse files
tylerjereddyeric-wieser
authored andcommitted
MAINT: remove exec_command usage in ibm.py (#11901)
Replaced the usage of exec_command() in distutils ibm module with subprocess.check_output
1 parent 58ce075 commit 88c01b8

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • numpy/distutils/fcompiler

numpy/distutils/fcompiler/ibm.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import os
44
import re
55
import sys
6+
import subprocess
67

78
from numpy.distutils.fcompiler import FCompiler
8-
from numpy.distutils.exec_command import exec_command, find_executable
9+
from numpy.distutils.exec_command import find_executable
910
from numpy.distutils.misc_util import make_temp_file
1011
from distutils import log
1112

@@ -35,9 +36,13 @@ def get_version(self,*args,**kwds):
3536
lslpp = find_executable('lslpp')
3637
xlf = find_executable('xlf')
3738
if os.path.exists(xlf) and os.path.exists(lslpp):
38-
s, o = exec_command(lslpp + ' -Lc xlfcmp')
39-
m = re.search(r'xlfcmp:(?P<version>\d+([.]\d+)+)', o)
40-
if m: version = m.group('version')
39+
try:
40+
o = subprocess.check_output([lslpp, '-Lc', 'xlfcmp'])
41+
except (OSError, subprocess.CalledProcessError):
42+
pass
43+
else:
44+
m = re.search(r'xlfcmp:(?P<version>\d+([.]\d+)+)', o)
45+
if m: version = m.group('version')
4146

4247
xlf_dir = '/etc/opt/ibmcmp/xlf'
4348
if version is None and os.path.isdir(xlf_dir):

0 commit comments

Comments
 (0)