diff --git a/CHANGES.txt b/CHANGES.txt index ac84431b2b..c17b1a68b9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -15,6 +15,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From John Doe: - Whatever John Doe did. + From Thaddeus Crews: + - Nodes are now treated as PathLike objects. + From Mats Wichmann: - Fix typos in CCFLAGS test. Didn't affect the test itself, but didn't correctly apply the DefaultEnvironment speedup. diff --git a/RELEASE.txt b/RELEASE.txt index 9a9fa1e2fc..ed7a0e0c34 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -29,6 +29,8 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY - List modifications to existing features, where the previous behavior wouldn't actually be considered a bug +- Nodes are now treated as PathLike objects. + FIXES ----- diff --git a/SCons/Builder.py b/SCons/Builder.py index c81d104143..870596f0c7 100644 --- a/SCons/Builder.py +++ b/SCons/Builder.py @@ -114,6 +114,7 @@ from SCons.Debug import logInstanceCreation from SCons.Errors import InternalError, UserError from SCons.Executor import Executor +from SCons.Node import Node class _Null: pass @@ -487,10 +488,11 @@ def _adjustixes(self, files, pre, suf, ensure_suffix: bool=False): # fspath() is to catch PathLike paths. We avoid the simpler # str(f) so as not to "lose" files that are already Nodes: # TypeError: expected str, bytes or os.PathLike object, not File - with suppress(TypeError): - f = os.fspath(f) - if SCons.Util.is_String(f): - f = SCons.Util.adjustixes(f, pre, suf, ensure_suffix) + if not isinstance(f, Node): + with suppress(TypeError): + f = os.fspath(f) + if SCons.Util.is_String(f): + f = SCons.Util.adjustixes(f, pre, suf, ensure_suffix) result.append(f) return result diff --git a/SCons/BuilderTests.py b/SCons/BuilderTests.py index adfa648280..fff26171e9 100644 --- a/SCons/BuilderTests.py +++ b/SCons/BuilderTests.py @@ -702,7 +702,7 @@ def test_single_source(self) -> None: """Test Builder with single_source flag set""" def func(target, source, env) -> None: """create the file""" - with open(str(target[0]), "w"): + with open(target[0], "w"): pass if len(source) == 1 and len(target) == 1: env['CNT'][0] = env['CNT'][0] + 1 @@ -759,7 +759,7 @@ def test_lists(self) -> None: """Testing handling lists of targets and source""" def function2(target, source, env, tlist = [outfile, outfile2], **kw) -> int: for t in target: - with open(str(t), 'w') as f: + with open(t, 'w') as f: f.write("function2\n") for t in tlist: if t not in list(map(str, target)): @@ -790,7 +790,7 @@ def function2(target, source, env, tlist = [outfile, outfile2], **kw) -> int: def function3(target, source, env, tlist = [sub1_out, sub2_out]) -> int: for t in target: - with open(str(t), 'w') as f: + with open(t, 'w') as f: f.write("function3\n") for t in tlist: if t not in list(map(str, target)): diff --git a/SCons/Environment.xml b/SCons/Environment.xml index e59ab02f7b..d5e436531d 100644 --- a/SCons/Environment.xml +++ b/SCons/Environment.xml @@ -1248,7 +1248,7 @@ env.Command( import os def rename(env, target, source): - os.rename('.tmp', str(target[0])) + os.rename('.tmp', target[0]) env.Command( @@ -3626,7 +3626,7 @@ def create(target, source, env): Writes 'prefix=$SOURCE' into the file name given as $TARGET. """ - with open(str(target[0]), 'wb') as f: + with open(target[0], 'wb') as f: f.write(b'prefix=' + source[0].get_contents() + b'\n') # Fetch the prefix= argument, if any, from the command line. diff --git a/SCons/Node/__init__.py b/SCons/Node/__init__.py index 055c3090cb..dba1c968c6 100644 --- a/SCons/Node/__init__.py +++ b/SCons/Node/__init__.py @@ -622,6 +622,9 @@ def __init__(self) -> None: # what line in what file created the node, for example). Annotate(self) + def __fspath__(self) -> str: + return str(self) + def disambiguate(self, must_exist: bool = False): return self diff --git a/SCons/SConfTests.py b/SCons/SConfTests.py index 520b02ff09..4a3c8b25dd 100644 --- a/SCons/SConfTests.py +++ b/SCons/SConfTests.py @@ -295,7 +295,7 @@ def test_TryAction(self) -> None: """Test SConf.TryAction """ def actionOK(target, source, env): - with open(str(target[0]), "w") as f: + with open(target[0], "w") as f: f.write("RUN OK\n") return None def actionFAIL(target, source, env) -> int: diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py index 7e47c9613e..6f57085126 100644 --- a/bin/SConsExamples.py +++ b/bin/SConsExamples.py @@ -547,7 +547,7 @@ def process(source_file, ofp): elif line[:11] != "STRIP CCCOM": ofp.write(line) - with open(str(target[0]), "w") as fp: + with open(target[0], "w") as fp: for src in map(str, source): process(src, fp) fp.write('debug = ' + ARGUMENTS.get('debug', '0') + '\\n') diff --git a/test/Actions/append.py b/test/Actions/append.py index 8205e1beff..dcc9898387 100644 --- a/test/Actions/append.py +++ b/test/Actions/append.py @@ -45,13 +45,13 @@ env=Environment() def before(env, target, source): - with open(str(target[0]), "wb") as f: + with open(target[0], "wb") as f: f.write(b"Foo\\n") with open("before.txt", "wb") as f: f.write(b"Bar\\n") def after(env, target, source): - with open(str(target[0]), "rb") as fin, open("after%s", "wb") as fout: + with open(target[0], "rb") as fin, open("after%s", "wb") as fout: fout.write(fin.read()) env.Prepend(LINKCOM=Action(before)) diff --git a/test/Actions/exitstatfunc.py b/test/Actions/exitstatfunc.py index 7d5b2b976d..53e8477065 100644 --- a/test/Actions/exitstatfunc.py +++ b/test/Actions/exitstatfunc.py @@ -38,7 +38,7 @@ def always_succeed(s): return 0 def copy_fail(target, source, env): - with open(str(source[0]), 'rb') as infp, open(str(target[0]), 'wb') as f: + with open(source[0], 'rb') as infp, open(target[0], 'wb') as f: f.write(infp.read()) return 2 diff --git a/test/Actions/function.py b/test/Actions/function.py index 0b191e4044..fd5d5f0257 100644 --- a/test/Actions/function.py +++ b/test/Actions/function.py @@ -69,7 +69,7 @@ def writeDeps(target, source, env, b=%(b)s, r=r %(extraarg)s , header=header, tr def foo(b=b): return %(nestedfuncexp)s - with open(str(target[0]), 'wb') as f: + with open(target[0], 'wb') as f: f.write(bytearray(header, 'utf-8')) for d in env['ENVDEPS']: f.write(bytearray(d+'%(separator)s', 'utf-8')) diff --git a/test/Actions/pre-post-fixture/work2/SConstruct b/test/Actions/pre-post-fixture/work2/SConstruct index 347dcbe6f1..b2079f320e 100644 --- a/test/Actions/pre-post-fixture/work2/SConstruct +++ b/test/Actions/pre-post-fixture/work2/SConstruct @@ -3,7 +3,7 @@ # Copyright The SCons Foundation def b(target, source, env): - with open(str(target[0]), 'wb') as f: + with open(target[0], 'wb') as f: f.write((env['X'] + '\n').encode()) DefaultEnvironment(tools=[]) diff --git a/test/Actions/pre-post-fixture/work3/SConstruct b/test/Actions/pre-post-fixture/work3/SConstruct index 54f537ac8d..db63503d71 100644 --- a/test/Actions/pre-post-fixture/work3/SConstruct +++ b/test/Actions/pre-post-fixture/work3/SConstruct @@ -9,7 +9,7 @@ def post(target, source, env): pass def build(target, source, env): - with open(str(target[0]), 'wb') as f: + with open(target[0], 'wb') as f: f.write(b'build()\n') DefaultEnvironment(tools=[]) diff --git a/test/Actions/pre-post.py b/test/Actions/pre-post.py index 0d9f36fce9..14a9b85292 100644 --- a/test/Actions/pre-post.py +++ b/test/Actions/pre-post.py @@ -52,7 +52,7 @@ def before(env, target, source): f.write(b"Foo\\n") os.chmod(a, os.stat(a).st_mode | stat.S_IXUSR) with open("before.txt", "ab") as f: - f.write((os.path.splitext(str(target[0]))[0] + "\\n").encode()) + f.write((os.path.splitext(target[0])[0] + "\\n").encode()) def after(env, target, source): t = str(target[0]) @@ -104,11 +104,11 @@ def after(env, target, source): DefaultEnvironment(tools=[]) def pre_action(target, source, env): - with open(str(target[0]), 'ab') as f: + with open(target[0], 'ab') as f: f.write(('pre %%s\\n' %% source[0]).encode()) def post_action(target, source, env): - with open(str(target[0]), 'ab') as f: + with open(target[0], 'ab') as f: f.write(('post %%s\\n' %% source[0]).encode()) env = Environment(tools=[]) diff --git a/test/Actions/timestamp.py b/test/Actions/timestamp.py index d94a287ce4..e13ec005a6 100644 --- a/test/Actions/timestamp.py +++ b/test/Actions/timestamp.py @@ -45,7 +45,7 @@ test.write('SConstruct', """\ def my_copy(target, source, env): - with open(str(target[0]), 'w') as f, open(str(source[0]), 'r') as infp: + with open(target[0], 'w') as f, open(source[0], 'r') as infp: f.write(infp.read()) env = Environment() env.Decider('timestamp-match') diff --git a/test/Actions/unicode-signature-fixture/SConstruct b/test/Actions/unicode-signature-fixture/SConstruct index 95c969d29c..3e56b98861 100644 --- a/test/Actions/unicode-signature-fixture/SConstruct +++ b/test/Actions/unicode-signature-fixture/SConstruct @@ -5,7 +5,7 @@ fnode = File(u'foo.txt') def funcact(target, source, env): - with open(str(target[0]), 'wb') as f: + with open(target[0], 'wb') as f: f.write(b"funcact\n") for i in range(300): pass diff --git a/test/Alias/action.py b/test/Alias/action.py index 7eff1c7787..9a26be1dd4 100644 --- a/test/Alias/action.py +++ b/test/Alias/action.py @@ -33,10 +33,9 @@ test.write('SConstruct', """ def cat(target, source, env): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: f.write(ifp.read()) def foo(target, source, env): diff --git a/test/Alias/scanner.py b/test/Alias/scanner.py index 4f7473b672..2d983c04d6 100644 --- a/test/Alias/scanner.py +++ b/test/Alias/scanner.py @@ -35,10 +35,9 @@ test.write('SConstruct', """ DefaultEnvironment(tools=[]) def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: f.write(ifp.read()) XBuilder = Builder(action = cat, src_suffix = '.x', suffix = '.c') diff --git a/test/Batch/Boolean.py b/test/Batch/Boolean.py index 702d24befb..f4bc2ce6d1 100644 --- a/test/Batch/Boolean.py +++ b/test/Batch/Boolean.py @@ -37,7 +37,7 @@ def batch_build(target, source, env): for t, s in zip(target, source): - with open(str(t), 'wb') as f, open(str(s), 'rb') as infp: + with open(t, 'wb') as f, open(s, 'rb') as infp: f.write(infp.read()) env = Environment(tools=[]) bb = Action(batch_build, batch_key=True) diff --git a/test/Batch/callable.py b/test/Batch/callable.py index 5c4d816d3c..cc7e8e371c 100644 --- a/test/Batch/callable.py +++ b/test/Batch/callable.py @@ -40,7 +40,7 @@ DefaultEnvironment(tools=[]) def batch_build(target, source, env): for t, s in zip(target, source): - with open(str(t), 'wb') as f, open(str(s), 'rb') as infp: + with open(t, 'wb') as f, open(s, 'rb') as infp: f.write(infp.read()) if ARGUMENTS.get('BATCH_CALLABLE'): def batch_key(action, env, target, source): diff --git a/test/Batch/generated.py b/test/Batch/generated.py index cb76ff2b7c..59db0f82e6 100644 --- a/test/Batch/generated.py +++ b/test/Batch/generated.py @@ -37,11 +37,11 @@ def batch_build(target, source, env): for t, s in zip(target, source): - with open(str(t), 'wb') as fp: + with open(t, 'wb') as fp: if str(t) == 'f3.out': with open('f3.include', 'rb') as f: fp.write(f.read()) - with open(str(s), 'rb') as f: + with open(s, 'rb') as f: fp.write(f.read()) env = Environment(tools=[]) bb = Action(batch_build, batch_key=True) diff --git a/test/Builder-factories.py b/test/Builder-factories.py index e1fb65ce3e..229b4972a0 100644 --- a/test/Builder-factories.py +++ b/test/Builder-factories.py @@ -47,7 +47,7 @@ def mkdir(env, source, target): f.write(b"MakeDirectory\\n") MakeDirectory = Builder(action=mkdir, target_factory=Dir) def collect(env, source, target): - with open(str(target[0]), 'wb') as out: + with open(target[0], 'wb') as out: dir = str(source[0]) for f in sorted(os.listdir(dir)): f = os.path.join(dir, f) diff --git a/test/Builder/errors.py b/test/Builder/errors.py index 7a713a3aac..1e6a3a0fef 100644 --- a/test/Builder/errors.py +++ b/test/Builder/errors.py @@ -38,7 +38,7 @@ DefaultEnvironment(tools=[]) def buildop(env, source, target): - with open(str(target[0]), 'wb') as outf, open(str(source[0]), 'r') as infp: + with open(target[0], 'wb') as outf, open(source[0], 'r') as infp: for line in inpf.readlines(): if line.find(str(target[0])) == -1: outf.write(line) diff --git a/test/Builder/multi/different-actions.py b/test/Builder/multi/different-actions.py index ec07b624e0..53141e8400 100644 --- a/test/Builder/multi/different-actions.py +++ b/test/Builder/multi/different-actions.py @@ -36,9 +36,9 @@ test.write('SConstruct', """\ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) B = Builder(action=Action(build, varlist=['XXX']), multi=1) diff --git a/test/Builder/multi/different-environments.py b/test/Builder/multi/different-environments.py index 82b10ecb1f..41b59d81cc 100644 --- a/test/Builder/multi/different-environments.py +++ b/test/Builder/multi/different-environments.py @@ -39,10 +39,10 @@ test.write('build.py', r"""\ import sys def build(num, target, source): - with open(str(target), 'wb') as f: + with open(target[0], 'wb') as f: f.write('%s\n' % num) - for s in source: - with open(str(s), 'rb') as infp: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) build(sys.argv[1],sys.argv[2],sys.argv[3:]) """) diff --git a/test/Builder/multi/different-multi.py b/test/Builder/multi/different-multi.py index 3084bf5381..0adabf7d74 100644 --- a/test/Builder/multi/different-multi.py +++ b/test/Builder/multi/different-multi.py @@ -37,9 +37,9 @@ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) def build2(env, target, source): diff --git a/test/Builder/multi/different-order.py b/test/Builder/multi/different-order.py index 4018159e18..6fc800d5f6 100644 --- a/test/Builder/multi/different-order.py +++ b/test/Builder/multi/different-order.py @@ -39,9 +39,9 @@ DefaultEnvironment(tools=[]) def build(env, target, source): for t in target: - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) B = Builder(action=build, multi=1) diff --git a/test/Builder/multi/different-overrides.py b/test/Builder/multi/different-overrides.py index c4267f300c..57418aa2b6 100644 --- a/test/Builder/multi/different-overrides.py +++ b/test/Builder/multi/different-overrides.py @@ -36,9 +36,9 @@ test.write('SConstruct', """\ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) B = Builder(action=build, multi=1) diff --git a/test/Builder/multi/different-target-lists.py b/test/Builder/multi/different-target-lists.py index 4b6c49e723..5c3ea76605 100644 --- a/test/Builder/multi/different-target-lists.py +++ b/test/Builder/multi/different-target-lists.py @@ -43,9 +43,9 @@ DefaultEnvironment(tools=[]) def build(env, target, source): for t in target: - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) B = Builder(action=build, multi=1) diff --git a/test/Builder/multi/error.py b/test/Builder/multi/error.py index 3b2a8d493c..ae3f48d795 100644 --- a/test/Builder/multi/error.py +++ b/test/Builder/multi/error.py @@ -37,9 +37,9 @@ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) B = Builder(action=build, multi=0) diff --git a/test/Builder/multi/lone-target-list.py b/test/Builder/multi/lone-target-list.py index 885d34a99c..0a1450066b 100644 --- a/test/Builder/multi/lone-target-list.py +++ b/test/Builder/multi/lone-target-list.py @@ -37,9 +37,9 @@ def build(env, target, source): for t in target: - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(t, 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) B = Builder(action=build, multi=1) diff --git a/test/Builder/multi/multi.py b/test/Builder/multi/multi.py index aec09513e5..140b8c4378 100644 --- a/test/Builder/multi/multi.py +++ b/test/Builder/multi/multi.py @@ -37,9 +37,9 @@ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) B = Builder(action=build, multi=1) diff --git a/test/Builder/multi/same-actions.py b/test/Builder/multi/same-actions.py index f2a8fe3ec2..7b56dd045d 100644 --- a/test/Builder/multi/same-actions.py +++ b/test/Builder/multi/same-actions.py @@ -37,9 +37,9 @@ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) B = Builder(action=build, multi=1) diff --git a/test/Builder/multi/same-overrides.py b/test/Builder/multi/same-overrides.py index c545329ef6..9b5698bca3 100644 --- a/test/Builder/multi/same-overrides.py +++ b/test/Builder/multi/same-overrides.py @@ -37,10 +37,10 @@ test.write('build.py', r"""\ import sys def build(num, target, source): - with open(str(target), 'wb') as f: + with open(target, 'wb') as f: f.write(bytearray('%s\n'% num,'utf-8')) - for s in source: - with open(str(s), 'rb') as infp: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) build(sys.argv[1], sys.argv[2], sys.argv[3:]) """) diff --git a/test/Builder/multi/same-targets.py b/test/Builder/multi/same-targets.py index 17f6f990dc..f343a82e4e 100644 --- a/test/Builder/multi/same-targets.py +++ b/test/Builder/multi/same-targets.py @@ -38,9 +38,9 @@ def build(env, target, source): for t in target: - with open(str(t), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(t, 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) B = Builder(action=build, multi=1) diff --git a/test/Builder/non-multi.py b/test/Builder/non-multi.py index d540f6bf8b..83fc5230d3 100644 --- a/test/Builder/non-multi.py +++ b/test/Builder/non-multi.py @@ -36,9 +36,9 @@ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) B = Builder(action=build, multi=0) diff --git a/test/Builder/same-actions-diff-envs.py b/test/Builder/same-actions-diff-envs.py index 709b10850f..9d6fcbb049 100644 --- a/test/Builder/same-actions-diff-envs.py +++ b/test/Builder/same-actions-diff-envs.py @@ -36,7 +36,7 @@ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'w') as f: + with open(target[0], 'w') as f: f.write('1') B = Builder(action=build) diff --git a/test/Builder/same-actions-diff-overrides.py b/test/Builder/same-actions-diff-overrides.py index ba3ee9078d..cd7c1527d4 100644 --- a/test/Builder/same-actions-diff-overrides.py +++ b/test/Builder/same-actions-diff-overrides.py @@ -36,7 +36,7 @@ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'w') as f: + with open(target[0], 'w') as f: f.write('1') B = Builder(action=build) diff --git a/test/Builder/wrapper.py b/test/Builder/wrapper.py index 60f8b21baa..a4de067a88 100644 --- a/test/Builder/wrapper.py +++ b/test/Builder/wrapper.py @@ -38,9 +38,9 @@ import os.path import string def cat(target, source, env): - with open(str(target[0]), 'wb') as fp: - for s in map(str, source): - with open(s, 'rb') as infp: + with open(target[0], 'wb') as fp: + for src in source: + with open(src, 'rb') as infp: fp.write(infp.read()) Cat = Builder(action=cat) def Wrapper(env, target, source): diff --git a/test/CacheDir/CacheDir.py b/test/CacheDir/CacheDir.py index 05134e613a..45533b553c 100644 --- a/test/CacheDir/CacheDir.py +++ b/test/CacheDir/CacheDir.py @@ -56,7 +56,7 @@ def cat(env, source, target): f.write(target + "\\n") with open(target, "w") as f: for src in source: - with open(str(src), "r") as f2: + with open(src, "r") as f2: f.write(f2.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') diff --git a/test/CacheDir/SideEffect.py b/test/CacheDir/SideEffect.py index ee808d6e40..88b3b043c0 100644 --- a/test/CacheDir/SideEffect.py +++ b/test/CacheDir/SideEffect.py @@ -42,12 +42,10 @@ def copy(source, target): f.write(f2.read()) def build(env, source, target): - s = str(source[0]) - t = str(target[0]) - copy(s, t) + copy(source[0], target[0]) if target[0].side_effects: - with open(str(target[0].side_effects[0]), "a") as side_effect: - side_effect.write(s + ' -> ' + t + '\\n') + with open(target[0].side_effects[0], "a") as side_effect: + side_effect.write(str(source[0]) + ' -> ' + str(target[0]) + '\\n') CacheDir(r'%(cache)s') diff --git a/test/CacheDir/VariantDir.py b/test/CacheDir/VariantDir.py index 8c449173a5..1b9d2bfa64 100644 --- a/test/CacheDir/VariantDir.py +++ b/test/CacheDir/VariantDir.py @@ -47,7 +47,7 @@ def cat(env, source, target): f.write(target + "\\n") with open(target, "w") as f: for src in source: - with open(str(src), "r") as f2: + with open(src, "r") as f2: f.write(f2.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') diff --git a/test/CacheDir/debug.py b/test/CacheDir/debug.py index a8c4e835d3..cf16f98d10 100644 --- a/test/CacheDir/debug.py +++ b/test/CacheDir/debug.py @@ -56,7 +56,7 @@ def cat(env, source, target): f.write(target + "\\n") with open(target, "w") as f: for src in source: - with open(str(src), "r") as f2: + with open(src, "r") as f2: f.write(f2.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') diff --git a/test/CacheDir/environment.py b/test/CacheDir/environment.py index 23e35087ac..26655ce7fc 100644 --- a/test/CacheDir/environment.py +++ b/test/CacheDir/environment.py @@ -57,7 +57,7 @@ def cat(env, source, target): f.write(target + "\\n") with open(target, "w") as f: for src in source: - with open(str(src), "r") as f2: + with open(src, "r") as f2: f.write(f2.read()) env_cache = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) env_nocache = env_cache.Clone() diff --git a/test/CacheDir/option--cd.py b/test/CacheDir/option--cd.py index df9ab47041..e3915880b4 100644 --- a/test/CacheDir/option--cd.py +++ b/test/CacheDir/option--cd.py @@ -43,7 +43,7 @@ def cat(env, source, target): f.write(target + "\\n") with open(target, "w") as f: for src in source: - with open(str(src), "r") as f2: + with open(src, "r") as f2: f.write(f2.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') diff --git a/test/CacheDir/option--cf.py b/test/CacheDir/option--cf.py index b34d706b77..52d107b7a0 100644 --- a/test/CacheDir/option--cf.py +++ b/test/CacheDir/option--cf.py @@ -44,7 +44,7 @@ def cat(env, source, target): f.write(target + "\\n") with open(target, "w") as f: for src in source: - with open(str(src), "r") as f2: + with open(src, "r") as f2: f.write(f2.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') diff --git a/test/CacheDir/option--cr.py b/test/CacheDir/option--cr.py index 4c423cfd19..a1d32d2277 100644 --- a/test/CacheDir/option--cr.py +++ b/test/CacheDir/option--cr.py @@ -43,7 +43,7 @@ def cat(env, source, target): f.write(target + "\\n") with open(target, "w") as f: for src in source: - with open(str(src), "r") as f2: + with open(src, "r") as f2: f.write(f2.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') diff --git a/test/CacheDir/option--cs.py b/test/CacheDir/option--cs.py index 62c0026f76..4a0bb33ffa 100644 --- a/test/CacheDir/option--cs.py +++ b/test/CacheDir/option--cs.py @@ -59,7 +59,7 @@ def cat(env, source, target): f.write(target + "\\n") with open(target, "w") as f: for src in source: - with open(str(src), "r") as f2: + with open(src, "r") as f2: f.write(f2.read()) DefaultEnvironment(tools=[]) # test speedup diff --git a/test/Chmod.py b/test/Chmod.py index 87e7b15acb..c1a83422b3 100644 --- a/test/Chmod.py +++ b/test/Chmod.py @@ -47,7 +47,7 @@ def cat(env, source, target): target = str(target[0]) with open(target, "wb") as f: for src in source: - with open(str(src), "rb") as infp: + with open(src, "rb") as infp: f.write(infp.read()) Cat = Action(cat) diff --git a/test/Climb/explicit-parent--D.py b/test/Climb/explicit-parent--D.py index c44dc38401..1d5c7460bd 100644 --- a/test/Climb/explicit-parent--D.py +++ b/test/Climb/explicit-parent--D.py @@ -40,7 +40,7 @@ def cat(env, source, target): target = str(target[0]) with open(target, 'wb') as ofp: for src in source: - with open(str(src), 'rb') as ifp: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) env.Cat('f1.out', 'f1.in') diff --git a/test/Climb/explicit-parent--U.py b/test/Climb/explicit-parent--U.py index a37d5a1608..e129b4aedd 100644 --- a/test/Climb/explicit-parent--U.py +++ b/test/Climb/explicit-parent--U.py @@ -40,7 +40,7 @@ def cat(env, source, target): target = str(target[0]) with open(target, 'wb') as ofp: for src in source: - with open(str(src), 'rb') as ifp: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) diff --git a/test/Climb/explicit-parent-u.py b/test/Climb/explicit-parent-u.py index c8c5da23e0..337e0b3827 100644 --- a/test/Climb/explicit-parent-u.py +++ b/test/Climb/explicit-parent-u.py @@ -41,7 +41,7 @@ def cat(env, source, target): target = str(target[0]) with open(target, 'wb') as ofp: for src in source: - with open(str(src), 'rb') as ifp: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) diff --git a/test/Climb/option-u.py b/test/Climb/option-u.py index b7298d2801..de98040786 100644 --- a/test/Climb/option-u.py +++ b/test/Climb/option-u.py @@ -45,7 +45,7 @@ def cat(env, source, target): target = str(target[0]) with open(target, 'wb') as ofp: for src in source: - with open(str(src), 'rb') as ifp: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env = Environment(tools=[]) env.Append(BUILDERS = {'Cat' : Builder(action=cat)}) diff --git a/test/Command.py b/test/Command.py index 5abdf169a6..687c13fffb 100644 --- a/test/Command.py +++ b/test/Command.py @@ -46,7 +46,7 @@ import sys def buildIt(env, target, source): - with open(str(target[0]), 'w') as f, open(str(source[0]), 'r') as infp: + with open(target[0], 'w') as f, open(source[0], 'r') as infp: xyzzy = env.get('XYZZY', '') if xyzzy: f.write(xyzzy + '\\n') diff --git a/test/Copy-Action.py b/test/Copy-Action.py index 1b1356e30e..c591011ad4 100644 --- a/test/Copy-Action.py +++ b/test/Copy-Action.py @@ -46,10 +46,9 @@ Execute(Copy('d7.out', Glob('f?.in'))) def cat(env, source, target): - target = str(target[0]) - with open(target, "w") as f: + with open(target[0], "w") as f: for src in source: - with open(str(src), "r") as ifp: + with open(src, "r") as ifp: f.write(ifp.read()) Cat = Action(cat) diff --git a/test/Decider/switch-rebuild.py b/test/Decider/switch-rebuild.py index 29264553cb..4cd09d6f5e 100644 --- a/test/Decider/switch-rebuild.py +++ b/test/Decider/switch-rebuild.py @@ -38,7 +38,7 @@ Decider('%s') def build(env, target, source): - with open(str(target[0]), 'wt') as f, open(str(source[0]), 'rt') as ifp: + with open(target[0], 'wt') as f, open(source[0], 'rt') as ifp: f.write(ifp.read()) B = Builder(action=build) env = Environment(tools=[], BUILDERS = { 'B' : B }) diff --git a/test/Delete.py b/test/Delete.py index fc4ab4fd3c..fff8946ddd 100644 --- a/test/Delete.py +++ b/test/Delete.py @@ -43,10 +43,9 @@ Execute(Delete('symlinks/dirlink')) def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as ofp: + with open(target[0], "wb") as ofp: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: ofp.write(ifp.read()) Cat = Action(cat) env = Environment() @@ -193,10 +192,9 @@ def cat(env, source, target): test.write("SConstruct", """\ def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as ifp: + with open(target[0], "wb") as ifp: for src in source: - with open(str(src), "rb") as ofp: + with open(src, "rb") as ofp: ofp.write(ifp.read()) Cat = Action(cat) env = Environment() diff --git a/test/Dir/source.py b/test/Dir/source.py index a0ba987956..21516bcdbd 100644 --- a/test/Dir/source.py +++ b/test/Dir/source.py @@ -44,7 +44,7 @@ DefaultEnvironment(tools=[]) def writeTarget(target, source, env): - f = open(str(target[0]), 'w') + f = open(target[0], 'w') f.write("stuff\\n") f.close() return 0 diff --git a/test/Errors/Exception.py b/test/Errors/Exception.py index cdd6a3c5ec..9c5f1681a2 100644 --- a/test/Errors/Exception.py +++ b/test/Errors/Exception.py @@ -30,7 +30,7 @@ test.write('SConstruct', """\ def foo(env, target, source): print(str(target[0])) - with open(str(target[0]), 'wt') as f: + with open(target[0], 'wt') as f: f.write('foo') def exit(env, target, source): diff --git a/test/Exit.py b/test/Exit.py index abaa382c0a..3aa690e44f 100644 --- a/test/Exit.py +++ b/test/Exit.py @@ -103,10 +103,9 @@ test.write(['subdir', 'SConscript'], """\ def exit_builder(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: f.write(ifp.read()) Exit(27) env = Environment(BUILDERS = {'my_exit' : Builder(action=exit_builder)}) @@ -132,10 +131,9 @@ def exit_scanner(node, env, target): exitscan = Scanner(function = exit_scanner, skeys = ['.k']) def cat(env, source, target): - target = str(target[0]) - with open(target, 'wb') as ofp: + with open(target[0], 'wb') as ofp: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: outf.write(ifp.read()) env = Environment(BUILDERS={'Cat':Builder(action=cat)}) diff --git a/test/FindFile.py b/test/FindFile.py index fa195c4d04..53612ae091 100644 --- a/test/FindFile.py +++ b/test/FindFile.py @@ -40,16 +40,16 @@ test.write('SConstruct', """ env = Environment(FILE = 'file', BAR = 'bar') file1 = FindFile('testfile1', [ 'foo', '.', 'bar', 'bar/baz' ]) -with open(str(file1), 'r') as f: +with open(file1, 'r') as f: print(f.read()) file2 = env.FindFile('test${FILE}1', [ 'bar', 'foo', '.', 'bar/baz' ]) -with open(str(file2), 'r') as f: +with open(file2, 'r') as f: print(f.read()) file3 = FindFile('testfile2', [ 'foo', '.', 'bar', 'bar/baz' ]) -with open(str(file3), 'r') as f: +with open(file3, 'r') as f: print(f.read()) file4 = env.FindFile('testfile2', [ '$BAR/baz', 'foo', '.', 'bar' ]) -with open(str(file4), 'r') as f: +with open(file4, 'r') as f: print(f.read()) """) diff --git a/test/Flatten.py b/test/Flatten.py index 40bbb3e08c..7f3acec513 100644 --- a/test/Flatten.py +++ b/test/Flatten.py @@ -36,10 +36,9 @@ test.write(['work', 'SConstruct'], """ def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as ofp: + with open(target[0], "wb") as ofp: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: ofp.write(ifp.read()) env = Environment(BUILDERS={'Cat':Builder(action=cat)}) f1 = env.Cat('../file1.out', 'file1.in') diff --git a/test/Glob/Repository.py b/test/Glob/Repository.py index 714bafa57a..b2b6195760 100644 --- a/test/Glob/Repository.py +++ b/test/Glob/Repository.py @@ -49,10 +49,9 @@ test.write(['repository', 'SConstruct'], """\ DefaultEnvironment(tools=[]) def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as ofp: + with open(target[0], 'wb') as ofp: for src in source: - with open(str(src), "rb") as ifp: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) # Verify that we can glob a repository-only Node that exists diff --git a/test/Glob/VariantDir.py b/test/Glob/VariantDir.py index 6340bb8007..3b64848b04 100644 --- a/test/Glob/VariantDir.py +++ b/test/Glob/VariantDir.py @@ -49,12 +49,12 @@ """) test.write(['src', 'SConscript'], """\ -env = Environment(tools=[]) +env = Environment(tools=[]) def concatenate(target, source, env): - with open(str(target[0]), 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + with open(target[0], 'wb') as ofp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env['BUILDERS']['Concatenate'] = Builder(action=concatenate) @@ -67,9 +67,9 @@ def concatenate(target, source, env): env = Environment(tools=[]) def concatenate(target, source, env): - with open(str(target[0]), 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + with open(target[0], 'wb') as ofp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env['BUILDERS']['Concatenate'] = Builder(action=concatenate) diff --git a/test/Glob/basic.py b/test/Glob/basic.py index 5e5cdb5ac2..53077ba93c 100644 --- a/test/Glob/basic.py +++ b/test/Glob/basic.py @@ -34,12 +34,12 @@ test.write('SConstruct', """\ DefaultEnvironment(tools=[]) -env = Environment(tools=[]) +env = Environment(tools=[]) def concatenate(target, source, env): - with open(str(target[0]), 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + with open(target[0], 'wb') as ofp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env['BUILDERS']['Concatenate'] = Builder(action=concatenate) diff --git a/test/Glob/exclude.py b/test/Glob/exclude.py index 658d99acd7..5c909cb186 100644 --- a/test/Glob/exclude.py +++ b/test/Glob/exclude.py @@ -37,12 +37,12 @@ test.write('SConstruct', """\ DefaultEnvironment(tools=[]) -env = Environment(tools=[]) +env = Environment(tools=[]) def concatenate(target, source, env): - with open(str(target[0]), 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + with open(target[0], 'wb') as ofp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env['BUILDERS']['Concatenate'] = Builder(action=concatenate) diff --git a/test/Glob/source.py b/test/Glob/source.py index 33aff85163..807d2d7de2 100644 --- a/test/Glob/source.py +++ b/test/Glob/source.py @@ -38,12 +38,12 @@ test.write('SConstruct', """\ DefaultEnvironment(tools=[]) -env = Environment(tools=[]) +env = Environment(tools=[]) def concatenate(target, source, env): - with open(str(target[0]), 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + with open(target[0], 'wb') as ofp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env['BUILDERS']['Concatenate'] = Builder(action=concatenate) diff --git a/test/Glob/strings.py b/test/Glob/strings.py index 2a4a624db6..76824f00f1 100644 --- a/test/Glob/strings.py +++ b/test/Glob/strings.py @@ -46,12 +46,12 @@ """) test.write(['src', 'SConscript'], """\ -env = Environment(tools=[]) +env = Environment(tools=[]) def concatenate(target, source, env): - with open(str(target[0]), 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + with open(target[0], 'wb') as ofp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env['BUILDERS']['Concatenate'] = Builder(action=concatenate) diff --git a/test/Glob/subdir.py b/test/Glob/subdir.py index 22439f7d07..63135ba08c 100644 --- a/test/Glob/subdir.py +++ b/test/Glob/subdir.py @@ -37,12 +37,12 @@ test.write('SConstruct', """\ DefaultEnvironment(tools=[]) -env = Environment(tools=[]) +env = Environment(tools=[]) def concatenate(target, source, env): - with open(str(target[0]), 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + with open(target[0], 'wb') as ofp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env['BUILDERS']['Concatenate'] = Builder(action=concatenate) diff --git a/test/Glob/subst.py b/test/Glob/subst.py index efbc916470..4b38779fc7 100644 --- a/test/Glob/subst.py +++ b/test/Glob/subst.py @@ -38,9 +38,9 @@ env = Environment(tools=[], PATTERN = 'f*.in') def copy(target, source, env): - with open(str(target[0]), 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + with open(target[0], 'wb') as ofp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) env['BUILDERS']['Copy'] = Builder(action=copy) diff --git a/test/HeaderGen.py b/test/HeaderGen.py index f66ef574de..10fa68639f 100644 --- a/test/HeaderGen.py +++ b/test/HeaderGen.py @@ -35,7 +35,7 @@ test.write('SConstruct', """\ def writeFile(target, contents): - with open(str(target[0]), 'w') as f: + with open(target[0], 'w') as f: f.write(contents) return 0 @@ -59,7 +59,7 @@ def writeFile(target, contents): env = Environment() def gen_a_h(target, source, env): - with open(str(target[0]), 'w') as t, open(str(source[0]), 'r') as s: + with open(target[0], 'w') as t, open(source[0], 'r') as s: s.readline() t.write(s.readline()[:-1] + ';\\n') diff --git a/test/Install/Install.py b/test/Install/Install.py index 802b10dae6..8bb9ed719c 100644 --- a/test/Install/Install.py +++ b/test/Install/Install.py @@ -50,10 +50,9 @@ test.write(['work', 'SConstruct'], """\ DefaultEnvironment(tools=[]) def cat(env, source, target): - target = str(target[0]) - with open(target, 'wb') as ofp: + with open(target[0], 'wb') as ofp: for src in source: - with open(str(src), 'rb') as ifp: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) def my_install(dest, source, env): diff --git a/test/Install/wrap-by-attribute.py b/test/Install/wrap-by-attribute.py index c18ea7757e..7cb645b2da 100644 --- a/test/Install/wrap-by-attribute.py +++ b/test/Install/wrap-by-attribute.py @@ -46,10 +46,9 @@ def cat(env, source, target): - target = str(target[0]) - with open(target, 'wb') as ofp: + with open(target[0], 'wb') as ofp: for src in source: - with open(str(src), 'rb') as ifp: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) diff --git a/test/Interactive/option-j.py b/test/Interactive/option-j.py index 356a06749a..60b8fcc7f4 100644 --- a/test/Interactive/option-j.py +++ b/test/Interactive/option-j.py @@ -40,8 +40,8 @@ def cat(target, source, env): t = str(target[0]) os.mkdir(t + '.started') with open(t, 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) os.mkdir(t + '.finished') @@ -64,8 +64,8 @@ def must_wait_for_f2_b_out(target, source, env): while not os.path.exists(f2_b_started): time.sleep(1) with open(t, 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) os.mkdir(t + '.finished') diff --git a/test/Mkdir.py b/test/Mkdir.py index 367c834952..d177232b66 100644 --- a/test/Mkdir.py +++ b/test/Mkdir.py @@ -40,10 +40,9 @@ Execute(Mkdir('d1')) Execute(Mkdir(Dir('#d1-Dir'))) def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: f.write(ifp.read()) Cat = Action(cat) env = Environment() diff --git a/test/Move.py b/test/Move.py index 1da3aa7b8a..aca8fa424e 100644 --- a/test/Move.py +++ b/test/Move.py @@ -36,10 +36,9 @@ Execute(Move('f1.out', 'f1.in')) Execute(Move('File-f1.out', File('f1.in-File'))) def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: f.write(ifp.read()) Cat = Action(cat) env = Environment() diff --git a/test/NodeOps.py b/test/NodeOps.py index a2db429dbd..5a19c642f8 100644 --- a/test/NodeOps.py +++ b/test/NodeOps.py @@ -64,9 +64,9 @@ if %(_E)s: import os derived = [N.is_derived() for N in Nodes] - real1 = [os.path.exists(str(N)) for N in Nodes] + real1 = [os.path.exists(N) for N in Nodes] exists = [N.exists() for N in Nodes] - real2 = [os.path.exists(str(N)) for N in Nodes] + real2 = [os.path.exists(N) for N in Nodes] for N,D,R,E,F in zip(Nodes, derived, real1, exists, real2): print('%%s: %%s %%s %%s %%s'%%(N,D,R,E,F)) foo.SharedLibrary(target = 'foo', source = 'foo%(_obj)s') @@ -119,13 +119,13 @@ Import('*') def mycopy(env, source, target): - with open(str(target[0]), 'wt') as fo, open(str(source[0]), 'rt') as fi: + with open(target[0], 'wt') as fo, open(source[0], 'rt') as fi: fo.write(fi.read()) def exists_test(node): - before = os.path.exists(str(node)) # doesn't exist yet in VariantDir + before = os.path.exists(node) # doesn't exist yet in VariantDir via_node = node.exists() # side effect causes copy from src - after = os.path.exists(str(node)) + after = os.path.exists(node) node.is_derived() import SCons.Script if GetOption('no_exec'): diff --git a/test/Repository/LIBPATH.py b/test/Repository/LIBPATH.py index 646b5d7e4f..9e19b3f64d 100644 --- a/test/Repository/LIBPATH.py +++ b/test/Repository/LIBPATH.py @@ -46,7 +46,7 @@ def write_LIBDIRFLAGS(env, target, source): pre = env.subst('$LIBDIRPREFIX') suf = env.subst('$LIBDIRSUFFIX') - with open(str(target[0]), 'w') as f: + with open(target[0], 'w') as f: for arg in env.subst('$_LIBDIRFLAGS', target=target).split(): if arg[:len(pre)] == pre: arg = arg[len(pre):] diff --git a/test/Repository/SConscript.py b/test/Repository/SConscript.py index 72e2d27bc5..3208304915 100644 --- a/test/Repository/SConscript.py +++ b/test/Repository/SConscript.py @@ -51,10 +51,9 @@ test.write(['rep1', 'src', 'SConscript'], """\ def cat(env, source, target): - target = str(target[0]) - with open(target, "w") as ofp: + with open(target[0], "w") as ofp: for src in source: - with open(str(src), "r") as ifp: + with open(src, "r") as ifp: ofp.write(ifp.read()) env = Environment(BUILDERS={'Cat':Builder(action=cat)}) @@ -88,10 +87,9 @@ def cat(env, source, target): test.write(['rep2', 'src', 'SConscript'], """\ def cat(env, source, target): - target = str(target[0]) - with open(target, "w") as ofp: + with open(target[0], "w") as ofp: for src in source: - with open(str(src), "r") as ifp: + with open(src, "r") as ifp: ofp.write(ifp.read()) env = Environment(BUILDERS={'Cat':Builder(action=cat)}) diff --git a/test/Repository/option-f.py b/test/Repository/option-f.py index f1b2cc6945..0dfea7504c 100644 --- a/test/Repository/option-f.py +++ b/test/Repository/option-f.py @@ -42,10 +42,9 @@ test.write(['repository', 'SConstruct'], """\ Repository(r'%s') def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as ofp: + with open(target[0], "wb") as ofp: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: ofp.write(ifp.read()) env = Environment(BUILDERS={'Build':Builder(action=cat)}) diff --git a/test/Requires/basic.py b/test/Requires/basic.py index 4851ac8b5b..2948d9da61 100644 --- a/test/Requires/basic.py +++ b/test/Requires/basic.py @@ -35,9 +35,9 @@ test.write('SConstruct', """ def append_prereq_func(target, source, env): - with open(str(target[0]), 'wb') as ofp: - for s in source: - with open(str(s), 'rb') as ifp: + with open(target[0], 'wb') as ofp: + for src in source: + with open(src, 'rb') as ifp: ofp.write(ifp.read()) with open('prereq.out', 'rb') as ifp: ofp.write(ifp.read()) diff --git a/test/Requires/eval-order.py b/test/Requires/eval-order.py index fddf232284..b076d51132 100644 --- a/test/Requires/eval-order.py +++ b/test/Requires/eval-order.py @@ -34,9 +34,9 @@ test.write('SConstruct', """ def copy_and_create_func(target, source, env): - with open(str(target[0]), 'w') as ofp: - for s in source: - with open(str(s), 'r') as ifp: + with open(target[0], 'w') as ofp: + for src in source: + with open(src, 'r') as ifp: ofp.write(ifp.read()) with open('file.in', 'w') as f: f.write("file.in 1\\n") diff --git a/test/Scanner/Scanner.py b/test/Scanner/Scanner.py index 4889d0f280..d64a7ab6cd 100644 --- a/test/Scanner/Scanner.py +++ b/test/Scanner/Scanner.py @@ -117,7 +117,7 @@ def third(env, target, source): contents = source[0].get_contents() # print("TYPE:"+str(type(contents))) contents = contents.replace(b'getfile', b'MISSEDME') - with open(str(target[0]), 'wb') as f: + with open(target[0], 'wb') as f: f.write(contents) kbld = Builder(action=r'%(_python_)s build.py $SOURCES $TARGET', diff --git a/test/Scanner/empty-implicit.py b/test/Scanner/empty-implicit.py index a1e7b032eb..33482d2a7c 100644 --- a/test/Scanner/empty-implicit.py +++ b/test/Scanner/empty-implicit.py @@ -37,11 +37,11 @@ import os.path def scan(node, env, envkey, arg): - print('XScanner: node = '+os.path.split(str(node))[1]) + print('XScanner: node = '+os.path.split(node)[1]) return [] def exists_check(node, env): - return os.path.exists(str(node)) + return os.path.exists(node) XScanner = Scanner(name = 'XScanner', function = scan, @@ -50,8 +50,8 @@ def exists_check(node, env): skeys = ['.x']) def echo(env, target, source): - t = os.path.split(str(target[0]))[1] - s = os.path.split(str(source[0]))[1] + t = os.path.split(target[0])[1] + s = os.path.split(source[0])[1] print('create %s from %s' % (t, s)) with open(t, 'wb') as ofb, open(s, 'rb') as ifb: ofb.write(ifb.read()) diff --git a/test/Scanner/exception.py b/test/Scanner/exception.py index 90791cb06c..c87d93df0b 100644 --- a/test/Scanner/exception.py +++ b/test/Scanner/exception.py @@ -67,10 +67,9 @@ def process(outf, inf): outf.write(line) def cat(env, source, target): - target = str(target[0]) - with open(target, 'wb') as outf: + with open(target[0], 'wb') as outf: for src in source: - with open(str(src), 'rb') as inf: + with open(src, 'rb') as inf: process(outf, inf) env = Environment(BUILDERS={'Cat':Builder(action=cat)}) diff --git a/test/Scanner/no-Dir-node.py b/test/Scanner/no-Dir-node.py index ef90934247..e10dc5d983 100644 --- a/test/Scanner/no-Dir-node.py +++ b/test/Scanner/no-Dir-node.py @@ -81,7 +81,7 @@ def process(infp, outfp): test.write('SConstruct', """\ def foo(target, source, env): - fp = open(str(target[0]), 'w') + fp = open(target[0], 'w') for c in sorted(source[0].children(), key=lambda t: t.name): fp.write('%s\\n' % c) fp.close() diff --git a/test/Scanner/scan-once.py b/test/Scanner/scan-once.py index bbe2594c2d..304b523762 100644 --- a/test/Scanner/scan-once.py +++ b/test/Scanner/scan-once.py @@ -36,11 +36,11 @@ import os.path def scan(node, env, envkey, arg): - print('XScanner: node = '+ os.path.split(str(node))[1]) + print('XScanner: node = '+ os.path.split(node)[1]) return [] def exists_check(node, env): - return os.path.exists(str(node)) + return os.path.exists(node) XScanner = Scanner(name = 'XScanner', function = scan, @@ -49,8 +49,8 @@ def exists_check(node, env): skeys = ['.x']) def echo(env, target, source): - t = os.path.split(str(target[0]))[1] - s = os.path.split(str(source[0]))[1] + t = os.path.split(target[0])[1] + s = os.path.split(source[0])[1] print('create %s from %s' % (t, s)) Echo = Builder(action = Action(echo, None), diff --git a/test/SideEffect/Issues/3013/files/SConstruct b/test/SideEffect/Issues/3013/files/SConstruct index 9294cb0308..9d897c2a4e 100644 --- a/test/SideEffect/Issues/3013/files/SConstruct +++ b/test/SideEffect/Issues/3013/files/SConstruct @@ -6,7 +6,7 @@ DefaultEnvironment(tools=[]) env = Environment() def make_file(target, source, env): - with open(str(target[0]), 'w') as f: + with open(target[0], 'w') as f: f.write('gobldygook') with open(str(target[0]) + '_side_effect', 'w') as side_effect: side_effect.write('anything') @@ -23,4 +23,3 @@ SConscript( exports={'env':env}, duplicate=0 ) - diff --git a/test/SideEffect/basic.py b/test/SideEffect/basic.py index b5b6381e21..aa8099c5d2 100644 --- a/test/SideEffect/basic.py +++ b/test/SideEffect/basic.py @@ -41,9 +41,9 @@ def copy(source, target): f.write(f2.read()) def build(env, source, target): - copy(str(source[0]), str(target[0])) + copy(source[0], target[0]) if target[0].side_effects: - with open(str(target[0].side_effects[0]), "ab") as side_effect: + with open(target[0].side_effects[0], "ab") as side_effect: side_effect.write(('%%s -> %%s\\n'%%(str(source[0]), str(target[0]))).encode()) Build = Builder(action=build) diff --git a/test/SideEffect/variant_dir.py b/test/SideEffect/variant_dir.py index 0e9ae532a5..3f815d313c 100644 --- a/test/SideEffect/variant_dir.py +++ b/test/SideEffect/variant_dir.py @@ -35,16 +35,16 @@ test = TestSCons.TestSCons() -test.write('SConstruct', +test.write('SConstruct', """ def copy(source, target): with open(target, "wb") as f, open(source, "rb") as f2: f.write(f2.read()) def build(env, source, target): - copy(str(source[0]), str(target[0])) + copy(source[0], target[0]) if target[0].side_effects: - with open(str(target[0].side_effects[0]), "ab") as side_effect: + with open(target[0].side_effects[0], "ab") as side_effect: side_effect.write(('%s -> %s\\n'%(str(source[0]), str(target[0]))).encode()) Build = Builder(action=build) diff --git a/test/TARGET-dir.py b/test/TARGET-dir.py index 652cf77516..a3cb8da08f 100644 --- a/test/TARGET-dir.py +++ b/test/TARGET-dir.py @@ -42,10 +42,9 @@ test.write('SConstruct', """ def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: f.write(ifp.read()) f.close() env = Environment(CPPPATH='${TARGET.dir}') diff --git a/test/Touch.py b/test/Touch.py index 3538c7d338..e3619466aa 100644 --- a/test/Touch.py +++ b/test/Touch.py @@ -38,10 +38,9 @@ Execute(Touch(File('f1-File'))) def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: f.write(ifp.read()) Cat = Action(cat) diff --git a/test/Value/Value.py b/test/Value/Value.py index 7bb48ca9f1..2995364201 100644 --- a/test/Value/Value.py +++ b/test/Value/Value.py @@ -52,7 +52,7 @@ def __str__(self): C = Custom(P) def create(target, source, env): - with open(str(target[0]), 'wb') as f: + with open(target[0], 'wb') as f: f.write(source[0].get_contents()) DefaultEnvironment(tools=[]) # test speedup @@ -68,7 +68,7 @@ def create_value(target, source, env): target[0].write(source[0].get_contents()) def create_value_file(target, source, env): - with open(str(target[0]), 'wb') as f: + with open(target[0], 'wb') as f: f.write(source[0].read()) env['BUILDERS']['B2'] = Builder(action=create_value) diff --git a/test/VariantDir/Clean.py b/test/VariantDir/Clean.py index 2e0d4c6827..1fc1269c3e 100644 --- a/test/VariantDir/Clean.py +++ b/test/VariantDir/Clean.py @@ -42,8 +42,7 @@ def build_sample(target, source, env): targetdir = str(target[0].dir) - target = str(target[0]) - with open(target, 'w') as ofd, open(str(source[0]), 'r') as ifd: + with open(target[0], 'w') as ofd, open(source[0], 'r') as ifd: ofd.write(ifd.read()) with open(targetdir+'/sample.junk', 'w') as f: f.write('Side effect!\\n') diff --git a/test/VariantDir/SConscript-variant_dir.py b/test/VariantDir/SConscript-variant_dir.py index 43c3638a1f..36198ceda2 100644 --- a/test/VariantDir/SConscript-variant_dir.py +++ b/test/VariantDir/SConscript-variant_dir.py @@ -57,10 +57,9 @@ var9 = Dir('../build/var9') def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as ofp: + with open(target[0], "wb") as ofp: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: ofp.write(ifp.read()) DefaultEnvironment(tools=[]) # test speedup diff --git a/test/VariantDir/VariantDir.py b/test/VariantDir/VariantDir.py index a173b86531..ef10022ae2 100644 --- a/test/VariantDir/VariantDir.py +++ b/test/VariantDir/VariantDir.py @@ -94,8 +94,8 @@ def buildIt(target, source, env): if not os.path.exists('build'): os.mkdir('build') - f1=open(str(source[0]), 'r') - f2=open(str(target[0]), 'w') + f1=open(source[0], 'r') + f2=open(target[0], 'w') f2.write(f1.read()) f2.close() f1.close() diff --git a/test/VariantDir/errors.py b/test/VariantDir/errors.py index 7400056e7e..b50eb318c7 100644 --- a/test/VariantDir/errors.py +++ b/test/VariantDir/errors.py @@ -59,10 +59,9 @@ def fake_scan(node, env, target): return [] def cat(env, source, target): - target = str(target[0]) - with open(target, "w") as f: + with open(target[0], "w") as f: for src in source: - with open(str(src), "r") as f2: + with open(src, "r") as f2: f.write(f2.read()) DefaultEnvironment(tools=[]) # test speedup diff --git a/test/Win32/default-drive.py b/test/Win32/default-drive.py index 7d19c57a5d..e1d8d4bf62 100644 --- a/test/Win32/default-drive.py +++ b/test/Win32/default-drive.py @@ -44,10 +44,9 @@ test.write(['src', 'SConstruct'], """ def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as ofp: + with open(target[0], "wb") as ofp: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: ofp.write(ifp.read()) env = Environment(BUILDERS={'Build':Builder(action=cat)}) diff --git a/test/chained-build.py b/test/chained-build.py index 10d0b46854..2cc3106771 100644 --- a/test/chained-build.py +++ b/test/chained-build.py @@ -37,7 +37,7 @@ SConstruct1_contents = """\ def build(env, target, source): - with open(str(target[0]), 'wt') as fo, open(str(source[0]), 'rt') as fi: + with open(target[0], 'wt') as fo, open(source[0], 'rt') as fi: fo.write(fi.read()) env=Environment(BUILDERS={'B' : Builder(action=build)}) @@ -46,7 +46,7 @@ def build(env, target, source): SConstruct2_contents = """\ def build(env, target, source): - with open(str(target[0]), 'wt') as fo, open(str(source[0]), 'rt') as fi: + with open(target[0], 'wt') as fo, open(source[0], 'rt') as fi: fo.write(fi.read()) env=Environment(BUILDERS={'B' : Builder(action=build)}) diff --git a/test/duplicate-sources.py b/test/duplicate-sources.py index 3ad29287c4..48a106dc53 100644 --- a/test/duplicate-sources.py +++ b/test/duplicate-sources.py @@ -35,9 +35,9 @@ test.write('SConstruct', """\ def cat(target, source, env): - with open(str(target[0]), 'wb') as t: - for s in source: - with open(str(s), 'rb') as s: + with open(target[0], 'wb') as t: + for src in source: + with open(src, 'rb') as s: t.write(s.read()) env = Environment(BUILDERS = {'Cat' : Builder(action = cat)}) env.Cat('out.txt', ['f1.in', 'f2.in', 'f1.in']) diff --git a/test/emitter.py b/test/emitter.py index d2a8b67b72..e454dc7110 100644 --- a/test/emitter.py +++ b/test/emitter.py @@ -41,7 +41,7 @@ test.write('src/SConscript',""" def build(target, source, env): for t in target: - with open(str(t), "wt") as f: + with open(t, "wt") as f: f.write(str(t)) def emitter(target, source, env): diff --git a/test/implicit-cache/basic.py b/test/implicit-cache/basic.py index 7eece88fe8..aa25327f97 100644 --- a/test/implicit-cache/basic.py +++ b/test/implicit-cache/basic.py @@ -62,7 +62,7 @@ SConscript('variant/SConscript', "env") def copy(target, source, env): - with open(str(target[0]), 'wt') as fo, open(str(source[0]), 'rt') as fi: + with open(target[0], 'wt') as fo, open(source[0], 'rt') as fi: fo.write(fi.read()) nodep = env.Command('nodeps.c', 'nodeps.in', action=copy) env.Program('nodeps', 'nodeps.c') diff --git a/test/implicit/changed-node.py b/test/implicit/changed-node.py index d89c14b8af..99ea01b0d7 100644 --- a/test/implicit/changed-node.py +++ b/test/implicit/changed-node.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# 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 +22,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 we don't throw an exception if a stored implicit @@ -46,13 +45,12 @@ def lister(target, source, env): import os - with open(str(target[0]), 'w') as ofp: - s = str(source[0]) - if os.path.isdir(s): - for l in os.listdir(str(source[0])): + with open(target[0], 'w') as ofp: + if os.path.isdir(source[0]): + for l in os.listdir(source[0]): ofp.write(l + '\\n') else: - ofp.write(s + '\\n') + ofp.write(f'{source[0]}\\n') builder = Builder(action=lister, source_factory=Dir, @@ -77,18 +75,18 @@ def lister(target, source, env): test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) SetOption('implicit_cache', 1) SetOption('max_drift', 1) def lister(target, source, env): import os.path - with open(str(target[0]), 'w') as ofp: - s = str(source[0]) - if os.path.isdir(s): - for l in os.listdir(str(source[0])): + with open(target[0], 'w') as ofp: + if os.path.isdir(source[0]): + for l in os.listdir(source[0]): ofp.write(l + '\\n') else: - ofp.write(s + '\\n') + ofp.write(f'{source[0]}\\n') builder = Builder(action=lister, source_factory=File) diff --git a/test/no-target.py b/test/no-target.py index bf5b94ae35..e16c8c07f7 100644 --- a/test/no-target.py +++ b/test/no-target.py @@ -41,10 +41,9 @@ test.write(subdir_SConscript, r""" def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: f.write(ifp.read()) b = Builder(action=cat, suffix='.out', src_suffix='.in') diff --git a/test/option/debug-memoizer.py b/test/option/debug-memoizer.py index 2425eaa0ca..7882646165 100644 --- a/test/option/debug-memoizer.py +++ b/test/option/debug-memoizer.py @@ -33,7 +33,7 @@ test.write('SConstruct', """ def cat(target, source, env): - with open(str(target[0]), 'wb') as f, open(str(source[0]), 'rb') as infp: + with open(target[0], 'wb') as f, open(source[0], 'rb') as infp: f.write(infp.read()) DefaultEnvironment(tools=[]) diff --git a/test/option/debug-memory.py b/test/option/debug-memory.py index 2958e0b7b7..1364da5d12 100644 --- a/test/option/debug-memory.py +++ b/test/option/debug-memory.py @@ -45,7 +45,7 @@ test.write('SConstruct', """ DefaultEnvironment(tools=[]) def cat(target, source, env): - with open(str(target[0]), 'wb') as f, open(str(source[0]), 'rb') as ifp: + with open(target[0], 'wb') as f, open(source[0], 'rb') as ifp: f.write(ifp.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=Action(cat))}) env.Cat('file.out', 'file.in') diff --git a/test/option/debug-multiple.py b/test/option/debug-multiple.py index 124e033e67..dc86c519ac 100644 --- a/test/option/debug-multiple.py +++ b/test/option/debug-multiple.py @@ -36,7 +36,7 @@ test.write('SConstruct', """ DefaultEnvironment(tools=[]) def cat(target, source, env): - with open(str(target[0]), 'wb') as f, open(str(source[0]), 'rb') as infp: + with open(target[0], 'wb') as f, open(source[0], 'rb') as infp: f.write(infp.read()) env = Environment(BUILDERS={'Cat':Builder(action=Action(cat))}) env.Cat('file.out', 'file.in') diff --git a/test/option/debug-objects.py b/test/option/debug-objects.py index 9c8536cb1f..57888460f0 100644 --- a/test/option/debug-objects.py +++ b/test/option/debug-objects.py @@ -36,7 +36,7 @@ test.write('SConstruct', """ DefaultEnvironment(tools=[]) def cat(target, source, env): - with open(str(target[0]), 'wb') as f, open(str(source[0]), 'rb') as infp: + with open(target[0], 'wb') as f, open(source[0], 'rb') as infp: f.write(infp.read()) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=Action(cat))}) env.Cat('file.out', 'file.in') diff --git a/test/option/debug-presub.py b/test/option/debug-presub.py index cbd5242eaf..0c5d2e9fe1 100644 --- a/test/option/debug-presub.py +++ b/test/option/debug-presub.py @@ -40,10 +40,9 @@ test.write('SConstruct', """\ DefaultEnvironment(tools=[]) def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as infp: + with open(src, "rb") as infp: f.write(infp.read()) FILE = Builder(action="$FILECOM") TEMP = Builder(action="$TEMPCOM") diff --git a/test/option/fixture/SConstruct_debug_count b/test/option/fixture/SConstruct_debug_count index 332815bde1..1a39d17e5f 100644 --- a/test/option/fixture/SConstruct_debug_count +++ b/test/option/fixture/SConstruct_debug_count @@ -4,7 +4,7 @@ if ARGUMENTS.get('JSON',False): DefaultEnvironment(tools=[]) def cat(target, source, env): - with open(str(target[0]), 'wb') as f, open(str(source[0]), 'rb') as infp: + with open(target[0], 'wb') as f, open(source[0], 'rb') as infp: f.write(infp.read()) env = Environment(BUILDERS={'Cat':Builder(action=Action(cat))}) env.Cat('file.out', 'file.in') diff --git a/test/option/option--random.py b/test/option/option--random.py index 1dafca4507..1521e3a44b 100644 --- a/test/option/option--random.py +++ b/test/option/option--random.py @@ -34,10 +34,9 @@ test.write('SConscript', """\ def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: f.write(ifp.read()) env = Environment(BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') diff --git a/test/option/warn-duplicate-environment.py b/test/option/warn-duplicate-environment.py index 1000647118..f19c533e82 100644 --- a/test/option/warn-duplicate-environment.py +++ b/test/option/warn-duplicate-environment.py @@ -36,9 +36,9 @@ test.write('SConstruct', """ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) WARN = ARGUMENTS.get('WARN') diff --git a/test/option/warn-misleading-keywords.py b/test/option/warn-misleading-keywords.py index 45236bb4b7..5f78e63f94 100644 --- a/test/option/warn-misleading-keywords.py +++ b/test/option/warn-misleading-keywords.py @@ -36,9 +36,9 @@ test.write('SConstruct', """ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as f: + for src in source: + with open(src, 'rb') as infp: f.write(infp.read()) WARN = ARGUMENTS.get('WARN') @@ -58,7 +58,7 @@ def build(env, target, source): scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\? """ + TestSCons.file_expr -test.run(arguments='.', +test.run(arguments='.', stderr=expect + expect) test.must_match(['file3a'], 'file3a.in\n') diff --git a/test/sconsign/corrupt.py b/test/sconsign/corrupt.py index fa6a0e9cbc..301fd1b852 100644 --- a/test/sconsign/corrupt.py +++ b/test/sconsign/corrupt.py @@ -47,7 +47,7 @@ SConstruct_contents = """\ def build1(target, source, env): - with open(str(target[0]), 'wb') as ofp, open(str(source[0]), 'rb') as ifp: + with open(target[0], 'wb') as ofp, open(source[0], 'rb') as ifp: ofp.write(ifp.read()) return None diff --git a/test/sconsign/ghost-entries.py b/test/sconsign/ghost-entries.py index 59a1ec2054..2c9c98c035 100644 --- a/test/sconsign/ghost-entries.py +++ b/test/sconsign/ghost-entries.py @@ -51,9 +51,9 @@ test.write('SConstruct', """\ def cat(target, source, env): - with open(str(target[0]), 'wb') as fp: - for s in source: - with open(str(s), 'rb') as infp: + with open(target[0], 'wb') as fp: + for src in source: + with open(src, 'rb') as infp: fp.write(infp.read()) env=Environment() Export('env') diff --git a/test/sconsign/nonwritable.py b/test/sconsign/nonwritable.py index e9520780bd..ee7b13eb95 100644 --- a/test/sconsign/nonwritable.py +++ b/test/sconsign/nonwritable.py @@ -52,16 +52,16 @@ SConstruct_contents = """\ def build1(target, source, env): - with open(str(target[0]), 'wb') as fo, open(str(source[0]), 'rb') as fi: + with open(target[0], 'wb') as fo, open(source[0], 'rb') as fi: fo.write(fi.read()) return None def build2(target, source, env): import os import os.path - with open(str(target[0]), 'wb') as fo, open(str(source[0]), 'rb') as fi: + with open(target[0], 'wb') as fo, open(source[0], 'rb') as fi: fo.write(fi.read()) - dir, file = os.path.split(str(target[0])) + dir, file = os.path.split(target[0]) os.chmod(dir, 0o555) return None diff --git a/test/srcchange.py b/test/srcchange.py index e72d923a22..2eac09d743 100644 --- a/test/srcchange.py +++ b/test/srcchange.py @@ -52,7 +52,7 @@ def subrevision(target, source ,env): new = re.sub(r'\$REV.*?\$', '$REV: %%s$'%%source[0].get_text_contents().strip(), target[0].get_text_contents()) - with open(str(target[0]),'w') as outf: + with open(target[0], 'w') as outf: outf.write(new) SubRevision = Action(subrevision) diff --git a/test/suffixes.py b/test/suffixes.py index 7684ee83a9..a7a2c9d65f 100644 --- a/test/suffixes.py +++ b/test/suffixes.py @@ -34,10 +34,9 @@ test.write('SConstruct', """ def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: + with open(target[0], "wb") as f: for src in source: - with open(str(src), "rb") as ifp: + with open(src, "rb") as ifp: f.write(ifp.read()) Cat = Builder(action=cat, suffix='.out') env = Environment(BUILDERS = {'Cat':Cat}) diff --git a/test/timestamp-fallback.py b/test/timestamp-fallback.py index b3e812b911..d3f6774a09 100644 --- a/test/timestamp-fallback.py +++ b/test/timestamp-fallback.py @@ -57,7 +57,7 @@ DefaultEnvironment(tools=[]) def build(env, target, source): - with open(str(target[0]), 'wt') as ofp, open(str(source[0]), 'rt') as ifp: + with open(target[0], 'wt') as ofp, open(source[0], 'rt') as ifp: ofp.write(ifp.read()) B = Builder(action = build) diff --git a/test/toolpath/VariantDir.py b/test/toolpath/VariantDir.py index 652dde59b5..94376fc7c0 100644 --- a/test/toolpath/VariantDir.py +++ b/test/toolpath/VariantDir.py @@ -50,7 +50,7 @@ from SCons.Script import Builder def generate(env): def my_copy(target, source, env): - with open(str(target[0]), 'wb') as f, open(str(source[0]), 'rb') as ifp: + with open(target[0], 'wb') as f, open(source[0], 'rb') as ifp: f.write(ifp.read()) env['BUILDERS']['MyCopy'] = Builder(action = my_copy) diff --git a/timings/hundred/SConstruct b/timings/hundred/SConstruct index b321d10854..dce9ca79d3 100644 --- a/timings/hundred/SConstruct +++ b/timings/hundred/SConstruct @@ -25,7 +25,7 @@ target_count = int(ARGUMENTS['TARGET_COUNT']) def copy_files( env, target, source ): for t, s in zip(target, source): - open(str(t), 'wb').write(open(str(s), 'rb').read()) + open(t, 'wb').write(open(s, 'rb').read()) source_list = ['source_%04d' % t for t in range(target_count)] target_list = ['target_%04d' % t for t in range(target_count)]