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/command/install.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/command/install.py')
-rw-r--r-- | numpy/distutils/command/install.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/numpy/distutils/command/install.py b/numpy/distutils/command/install.py index a1dd47755..c74ae9446 100644 --- a/numpy/distutils/command/install.py +++ b/numpy/distutils/command/install.py @@ -64,16 +64,15 @@ class install(old_install): # bdist_rpm fails when INSTALLED_FILES contains # paths with spaces. Such paths must be enclosed # with double-quotes. - f = open(self.record, 'r') - lines = [] - need_rewrite = False - for l in f: - l = l.rstrip() - if ' ' in l: - need_rewrite = True - l = '"%s"' % (l) - lines.append(l) - f.close() + with open(self.record, 'r') as f: + lines = [] + need_rewrite = False + for l in f: + l = l.rstrip() + if ' ' in l: + need_rewrite = True + l = '"%s"' % (l) + lines.append(l) if need_rewrite: self.execute(write_file, (self.record, lines), |