diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-03-02 09:51:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-02 09:51:05 -0700 |
commit | e21d2cbdf15a86e16ef4877a42ed98d97ea296d3 (patch) | |
tree | 7edc523a692ad0067f44adf6d830d8ebc1898e1c /numpy/distutils/fcompiler | |
parent | 2f2dfa19839d69a20713b2fe05ca1ca35f6454a7 (diff) | |
parent | 73e6067c1ab5083a16150bb70aa7698a958dcd7b (diff) | |
download | numpy-e21d2cbdf15a86e16ef4877a42ed98d97ea296d3.tar.gz |
Merge pull request #13067 from eric-wieser/distutils-with-statement
MAINT: Use with statements for opening files in distutils
Diffstat (limited to 'numpy/distutils/fcompiler')
-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 |