diff options
author | jakobjakobson13 <43045863+jakobjakobson13@users.noreply.github.com> | 2020-08-11 18:34:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 11:34:40 -0500 |
commit | 25fa87a92d39c4a7de72f79263c9048d657b1226 (patch) | |
tree | f8b4ea30f7886f38e66751a9ae2a85f3e64301a1 | |
parent | 6aa1360ff7d305144a6b0ce8eb838897c0e1091a (diff) | |
download | numpy-25fa87a92d39c4a7de72f79263c9048d657b1226.tar.gz |
MAINT: change "for line in open()" to "with open() as f: ..." in numpy/distutils/misc_util.py (gh-#17051)
see #17012 item 13
Co-authored-by: Jakob <jakobjakobson13@posteo.de>
-rw-r--r-- | numpy/distutils/misc_util.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index d2a3149f7..aa649a23f 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -1900,15 +1900,16 @@ class Configuration: revision0 = f.read().strip() branch_map = {} - for line in open(branch_cache_fn, 'r'): - branch1, revision1 = line.split()[:2] - if revision1==revision0: - branch0 = branch1 - try: - revision1 = int(revision1) - except ValueError: - continue - branch_map[branch1] = revision1 + with open(branch_cache_fn, 'r') as f: + for line in f: + branch1, revision1 = line.split()[:2] + if revision1==revision0: + branch0 = branch1 + try: + revision1 = int(revision1) + except ValueError: + continue + branch_map[branch1] = revision1 return branch_map.get(branch0) |