diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2019-02-28 00:45:55 -0800 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2019-03-01 20:36:10 -0800 |
commit | 73e6067c1ab5083a16150bb70aa7698a958dcd7b (patch) | |
tree | 7edc523a692ad0067f44adf6d830d8ebc1898e1c /numpy/distutils/fcompiler/ibm.py | |
parent | 2f2dfa19839d69a20713b2fe05ca1ca35f6454a7 (diff) | |
download | numpy-73e6067c1ab5083a16150bb70aa7698a958dcd7b.tar.gz |
MAINT: Use with statements for opening files in distutils
Not super important, but saves some lines. Only the low-hanging ones here.
Found while tracking down an unrelated ResourceWarning
Diffstat (limited to 'numpy/distutils/fcompiler/ibm.py')
-rw-r--r-- | numpy/distutils/fcompiler/ibm.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/numpy/distutils/fcompiler/ibm.py b/numpy/distutils/fcompiler/ibm.py index c4cb2fca7..70d2132e1 100644 --- a/numpy/distutils/fcompiler/ibm.py +++ b/numpy/distutils/fcompiler/ibm.py @@ -78,15 +78,14 @@ class IBMFCompiler(FCompiler): xlf_cfg = '/etc/opt/ibmcmp/xlf/%s/xlf.cfg' % version fo, new_cfg = make_temp_file(suffix='_xlf.cfg') log.info('Creating '+new_cfg) - fi = open(xlf_cfg, 'r') - crt1_match = re.compile(r'\s*crt\s*[=]\s*(?P<path>.*)/crt1.o').match - for line in fi: - m = crt1_match(line) - if m: - fo.write('crt = %s/bundle1.o\n' % (m.group('path'))) - else: - fo.write(line) - fi.close() + with open(xlf_cfg, 'r') as fi: + crt1_match = re.compile(r'\s*crt\s*[=]\s*(?P<path>.*)/crt1.o').match + for line in fi: + m = crt1_match(line) + if m: + fo.write('crt = %s/bundle1.o\n' % (m.group('path'))) + else: + fo.write(line) fo.close() opt.append('-F'+new_cfg) return opt |