diff options
author | Mats Wichmann <mats@linux.com> | 2019-02-14 19:42:00 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2019-02-14 22:13:16 (GMT) |
commit | 887f4a1b06ceed33ee6ba4c5589a32a607d6b001 (patch) | |
tree | 48de09819749eea0e8d134386892397809122769 /test/Fortran | |
parent | 334e11d04bb3be2f0ed93f929548e6cdc84c3158 (diff) | |
download | SCons-887f4a1b06ceed33ee6ba4c5589a32a607d6b001.zip SCons-887f4a1b06ceed33ee6ba4c5589a32a607d6b001.tar.gz SCons-887f4a1b06ceed33ee6ba4c5589a32a607d6b001.tar.bz2 |
Clean up some tests: use context managers
Plenty of complaints coming from Python 3.8alpha on unclosed files.
Targeted those areas which intersect with PyPy failures - this changeset
reduces the PyPy fails by 17 on the local test environment.
So this affects both Issue #3299 and the PyPy support project.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test/Fortran')
-rw-r--r-- | test/Fortran/link-with-cxx.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/Fortran/link-with-cxx.py b/test/Fortran/link-with-cxx.py index a29558e..bf10fc8 100644 --- a/test/Fortran/link-with-cxx.py +++ b/test/Fortran/link-with-cxx.py @@ -48,7 +48,8 @@ elif sys.argv[1][:5] == '/OUT:': outfile = open(sys.argv[1][5:], 'wb') infiles = sys.argv[2:] for infile in infiles: - outfile.write(open(infile, 'rb').read()) + with open(infile, 'rb') as f: + outfile.write(f.read()) outfile.close() sys.exit(0) """) @@ -69,7 +70,8 @@ import SCons.Tool.link def copier(target, source, env): s = str(source[0]) t = str(target[0]) - open(t, 'wb').write(open(s, 'rb').read()) + with open(t, 'wb') as fo, open(s, 'rb') as fi: + fo.write(fi.read()) env = Environment(CXX = r'%(_python_)s test_linker.py', CXXCOM = Action(copier), SMARTLINK = SCons.Tool.link.smart_link, |