diff options
author | William Deegan <bill@baddogconsulting.com> | 2022-01-23 00:17:48 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2022-01-23 00:17:48 (GMT) |
commit | 2f4b66afe976071ffb456235b2efc7099d528bbb (patch) | |
tree | cccd3049b0921d631be4c1e6eb16e4226fc640ad | |
parent | 8dd789185a386f0b15c46441d5b9166c40504776 (diff) | |
download | SCons-2f4b66afe976071ffb456235b2efc7099d528bbb.zip SCons-2f4b66afe976071ffb456235b2efc7099d528bbb.tar.gz SCons-2f4b66afe976071ffb456235b2efc7099d528bbb.tar.bz2 |
address a number of ResourceWarning: unclosed file <_io.TextIOWrapper name='progress.out' mode='w' encoding='UTF-8'> type warnings which are issued when running tests with python 3.9
-rw-r--r-- | SCons/Tool/gcc.py | 9 | ||||
-rw-r--r-- | SCons/Tool/gxx.py | 24 | ||||
-rw-r--r-- | test/Progress/file.py | 17 | ||||
-rw-r--r-- | test/ninja/ninja_test_sconscripts/sconstruct_ninja_command_line | 4 |
4 files changed, 30 insertions, 24 deletions
diff --git a/SCons/Tool/gcc.py b/SCons/Tool/gcc.py index 7e38599..9c29c22 100644 --- a/SCons/Tool/gcc.py +++ b/SCons/Tool/gcc.py @@ -74,14 +74,13 @@ def detect_version(env, cc): # GCC versions older than that, we should use --version and a # regular expression. # pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['-dumpversion'], - pipe=SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['--version'], + with SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['--version'], stdin='devnull', stderr='devnull', - stdout=subprocess.PIPE) - if pipe.wait() != 0: - return version + stdout=subprocess.PIPE) as pipe: + if pipe.wait() != 0: + return version - with pipe.stdout: # -dumpversion variant: # line = pipe.stdout.read().strip() # --version variant: diff --git a/SCons/Tool/gxx.py b/SCons/Tool/gxx.py index 88186cb..edb45e2 100644 --- a/SCons/Tool/gxx.py +++ b/SCons/Tool/gxx.py @@ -1,15 +1,6 @@ -"""SCons.Tool.g++ - -Tool-specific initialization for g++. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - +# MIT License # -# __COPYRIGHT__ +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -29,9 +20,16 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +"""SCons.Tool.g++ + +Tool-specific initialization for g++. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" import SCons.Tool diff --git a/test/Progress/file.py b/test/Progress/file.py index 3184a5b..391f1b4 100644 --- a/test/Progress/file.py +++ b/test/Progress/file.py @@ -1,6 +1,7 @@ #!/usr/bin/env python +# MIT License # -# __COPYRIGHT__ +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,9 +21,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Verify that the file= argument to Progress() allows us to redirect the @@ -36,9 +34,18 @@ import TestSCons test = TestSCons.TestSCons() test.write('SConstruct', """\ +import atexit env = Environment() env['BUILDERS']['C'] = Builder(action=Copy('$TARGET', '$SOURCE')) -Progress('stderr: $TARGET\\n', file=open('progress.out', 'w')) +fo = open('progress.out', 'w') +Progress('stderr: $TARGET\\n', file=fo) + +# close file at exit +def close_it(): + fo.close() + +atexit.register(close_it) + env.C('S1.out', 'S1.in') env.C('S2.out', 'S2.in') env.C('S3.out', 'S3.in') diff --git a/test/ninja/ninja_test_sconscripts/sconstruct_ninja_command_line b/test/ninja/ninja_test_sconscripts/sconstruct_ninja_command_line index 14ae633..4967912 100644 --- a/test/ninja/ninja_test_sconscripts/sconstruct_ninja_command_line +++ b/test/ninja/ninja_test_sconscripts/sconstruct_ninja_command_line @@ -8,5 +8,7 @@ env = Environment(variables=env_vars) env.VariantDir(env['OTHER_VAR'], 'src') env.Tool('ninja') -env.Textfile('$BUILD/bar2.c', open('src/foo.c').read()) +with open('src/foo.c') as foo: + env.Textfile('$BUILD/bar2.c', foo.read()) + env.Program(target = 'foo', source = '$BUILD/bar2.c', CPPPATH='src') |