summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Rodrigues <rodrigc@FreeBSD.org>2017-03-12 23:21:07 (GMT)
committerCraig Rodrigues <rodrigc@FreeBSD.org>2017-03-12 23:21:07 (GMT)
commitd6823296e39adc6f147ae64f9be6ce64b8bb4a3e (patch)
tree61f648bdc234084da9d784ce206edf332f979e4d
parentf5f057cd5399ca96ef521b16bd53e5b43daaaada (diff)
downloadSCons-d6823296e39adc6f147ae64f9be6ce64b8bb4a3e.zip
SCons-d6823296e39adc6f147ae64f9be6ce64b8bb4a3e.tar.gz
SCons-d6823296e39adc6f147ae64f9be6ce64b8bb4a3e.tar.bz2
Fix some bytes/str issues to fix py2/3.
-rw-r--r--test/DSUFFIXES.py4
-rw-r--r--test/DVIPDF/DVIPDFFLAGS.py4
-rw-r--r--test/DVIPS/DVIPSFLAGS.py4
-rw-r--r--test/Dir/source.py2
-rw-r--r--test/Ghostscript/GS.py6
-rw-r--r--test/Ghostscript/GSFLAGS.py6
-rw-r--r--test/HeaderGen.py6
-rw-r--r--test/Install/Install.py4
-rw-r--r--test/Repository/LIBPATH.py2
-rw-r--r--test/Value.py4
-rw-r--r--test/VariantDir/Clean.py2
-rw-r--r--test/VariantDir/File-create.py4
-rw-r--r--test/VariantDir/errors.py2
-rw-r--r--test/explain/get_csig.py2
-rw-r--r--test/gnutools.py46
15 files changed, 49 insertions, 49 deletions
diff --git a/test/DSUFFIXES.py b/test/DSUFFIXES.py
index bc441a5..46bdf83 100644
--- a/test/DSUFFIXES.py
+++ b/test/DSUFFIXES.py
@@ -38,8 +38,8 @@ test.write('mydc.py', r"""
import sys
def do_file(outf, inf):
for line in open(inf, 'rb').readlines():
- if line[:7] == 'import ':
- do_file(outf, line[7:-2]+'.d')
+ if line[:7] == b'import ':
+ do_file(outf, line[7:-2] + b'.d')
else:
outf.write(line)
outf = open(sys.argv[1], 'wb')
diff --git a/test/DVIPDF/DVIPDFFLAGS.py b/test/DVIPDF/DVIPDFFLAGS.py
index 51a4c42..3704d60 100644
--- a/test/DVIPDF/DVIPDFFLAGS.py
+++ b/test/DVIPDF/DVIPDFFLAGS.py
@@ -55,7 +55,7 @@ base_name = os.path.splitext(arg[0])[0]
infile = open(arg[0], 'r')
out_file = open(base_name+'.dvi', 'w')
for l in infile.readlines():
- if l[:6] != '#latex':
+ if l[:6] != b'#latex':
out_file.write(l)
sys.exit(0)
""")
@@ -114,7 +114,7 @@ if dvipdf and tex:
test.write("wrapper.py", """import os
import sys
cmd = " ".join(sys.argv[1:])
-open('%s', 'ab').write("%%s\\n" %% cmd)
+open('%s', 'a').write("%%s\\n" %% cmd)
os.system(cmd)
""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
diff --git a/test/DVIPS/DVIPSFLAGS.py b/test/DVIPS/DVIPSFLAGS.py
index 7aedf24..43b5be5 100644
--- a/test/DVIPS/DVIPSFLAGS.py
+++ b/test/DVIPS/DVIPSFLAGS.py
@@ -41,7 +41,7 @@ base_name = os.path.splitext(arg[0])[0]
infile = open(arg[0], 'r')
out_file = open(base_name+'.dvi', 'w')
for l in infile.readlines():
- if l[:4] != '#tex':
+ if l[:4] != b'#tex':
out_file.write(l)
sys.exit(0)
""")
@@ -55,7 +55,7 @@ base_name = os.path.splitext(arg[0])[0]
infile = open(arg[0], 'r')
out_file = open(base_name+'.dvi', 'w')
for l in infile.readlines():
- if l[:6] != '#latex':
+ if l[:6] != b'#latex':
out_file.write(l)
sys.exit(0)
""")
diff --git a/test/Dir/source.py b/test/Dir/source.py
index 8dbee1a..8e3bea6 100644
--- a/test/Dir/source.py
+++ b/test/Dir/source.py
@@ -44,7 +44,7 @@ test.subdir('tstamp', [ 'tstamp', 'subdir' ],
test.write('SConstruct', """\
def writeTarget(target, source, env):
f=open(str(target[0]), 'wb')
- f.write("stuff\\n")
+ f.write(b"stuff\\n")
f.close()
return 0
diff --git a/test/Ghostscript/GS.py b/test/Ghostscript/GS.py
index daeea09..d7a7456 100644
--- a/test/Ghostscript/GS.py
+++ b/test/Ghostscript/GS.py
@@ -41,7 +41,7 @@ import sys
outfile = open(sys.argv[1], 'wb')
infile = open(sys.argv[2], 'rb')
for l in infile.readlines():
- if l[:3] != '#ps':
+ if l[:3] != b'#ps':
outfile.write(l)
sys.exit(0)
""")
@@ -60,8 +60,8 @@ test.write('test1.ps', r"""This is a .ps test.
test.run(arguments = '.', stderr = None)
-test.fail_test(test.read('test1.pdf') != "This is a .ps test.\n")
-test.fail_test(test.read('test2.pdf') != "This is a .ps test.\n")
+test.fail_test(test.read('test1.pdf') != b"This is a .ps test.\n")
+test.fail_test(test.read('test2.pdf') != b"This is a .ps test.\n")
diff --git a/test/Ghostscript/GSFLAGS.py b/test/Ghostscript/GSFLAGS.py
index c8e0668..2e58ec1 100644
--- a/test/Ghostscript/GSFLAGS.py
+++ b/test/Ghostscript/GSFLAGS.py
@@ -48,9 +48,9 @@ for opt, arg in cmd_opts:
else:
opt_string = opt_string + ' ' + opt
infile = open(args[0], 'rb')
-out_file.write(opt_string + "\n")
+out_file.write(opt_string.encode("utf-8") + b"\n")
for l in infile.readlines():
- if l[:3] != '#ps':
+ if l[:3] != b'#ps':
out_file.write(l)
sys.exit(0)
""")
@@ -68,7 +68,7 @@ This is a .ps test.
test.run(arguments = '.', stderr = None)
-test.fail_test(test.read('test1.pdf') != " -x\nThis is a .ps test.\n")
+test.fail_test(test.read('test1.pdf') != b" -x\nThis is a .ps test.\n")
diff --git a/test/HeaderGen.py b/test/HeaderGen.py
index 5a7fdbe..2763b34 100644
--- a/test/HeaderGen.py
+++ b/test/HeaderGen.py
@@ -35,7 +35,7 @@ test = TestSCons.TestSCons()
test.write('SConstruct', """\
def writeFile(target, contents):
- file = open(str(target[0]), 'wb')
+ file = open(str(target[0]), 'w')
file.write(contents)
file.close()
return 0
@@ -60,8 +60,8 @@ test.write('SConstruct', """\
env = Environment()
def gen_a_h(target, source, env):
- t = open(str(target[0]), 'wb')
- s = open(str(source[0]), 'rb')
+ t = open(str(target[0]), 'w')
+ s = open(str(source[0]), 'r')
s.readline()
t.write(s.readline()[:-1] + ';\\n')
diff --git a/test/Install/Install.py b/test/Install/Install.py
index d66660b..8c3bccd 100644
--- a/test/Install/Install.py
+++ b/test/Install/Install.py
@@ -58,7 +58,7 @@ def cat(env, source, target):
def my_install(dest, source, env):
import shutil
shutil.copy2(source, dest)
- open('my_install.out', 'ab').write(dest)
+ open('my_install.out', 'a').write(dest)
env1 = Environment()
env1.Append(BUILDERS={'Cat':Builder(action=cat)})
@@ -122,7 +122,7 @@ test.fail_test(oldtime1 == os.path.getmtime(f1_out))
test.fail_test(oldtime2 != os.path.getmtime(f2_out))
# Verify that we didn't link to the Installed file.
-open(f2_out, 'wb').write("xyzzy\n")
+open(f2_out, 'wb').write(b"xyzzy\n")
test.must_match(['work', 'f2.out'], "f2.in\n")
# Verify that scons prints an error message
diff --git a/test/Repository/LIBPATH.py b/test/Repository/LIBPATH.py
index c95d29a..166060e 100644
--- a/test/Repository/LIBPATH.py
+++ b/test/Repository/LIBPATH.py
@@ -46,7 +46,7 @@ bbb_exe = env_yyy.Program('bbb', 'bbb.c')
def write_LIBDIRFLAGS(env, target, source):
pre = env.subst('$LIBDIRPREFIX')
suf = env.subst('$LIBDIRSUFFIX')
- f = open(str(target[0]), 'wb')
+ f = open(str(target[0]), 'w')
for arg in env.subst('$_LIBDIRFLAGS', target=target).split():
if arg[:len(pre)] == pre:
arg = arg[len(pre):]
diff --git a/test/Value.py b/test/Value.py
index 7abe758..34b036b 100644
--- a/test/Value.py
+++ b/test/Value.py
@@ -59,7 +59,7 @@ env.B('f3.out', Value(C))
env.S('f4.out', Value(L))
def create_value (target, source, env):
- target[0].write(source[0].get_contents ())
+ target[0].write(source[0].get_contents())
def create_value_file (target, source, env):
open(str(target[0]), 'wb').write(source[0].read())
@@ -75,7 +75,7 @@ env.B3('f5.out', V)
test.write('put.py', """\
import os
import sys
-open(sys.argv[-1],'wb').write(" ".join(sys.argv[1:-2]))
+open(sys.argv[-1],'w').write(" ".join(sys.argv[1:-2]))
""")
# Run all of the tests with both types of source signature
diff --git a/test/VariantDir/Clean.py b/test/VariantDir/Clean.py
index d1e0bb8..ca14738 100644
--- a/test/VariantDir/Clean.py
+++ b/test/VariantDir/Clean.py
@@ -44,7 +44,7 @@ def build_sample(target, source, env):
targetdir = str(target[0].dir)
target = str(target[0])
open(target, 'wb').write(open(str(source[0]), 'rb').read())
- open(targetdir+'/sample.junk', 'wb').write('Side effect!\\n')
+ open(targetdir+'/sample.junk', 'wb').write(b'Side effect!\\n')
t0 = Command("build0/sample.out", "sample.in", build_sample)
t1 = Command("build1/sample.out", "sample.in", build_sample)
diff --git a/test/VariantDir/File-create.py b/test/VariantDir/File-create.py
index 725404c..1386020 100644
--- a/test/VariantDir/File-create.py
+++ b/test/VariantDir/File-create.py
@@ -49,12 +49,12 @@ SConscript('src/SConscript', variant_dir='build1', chdir=1, duplicate=1)
test.write(['src', 'SConscript'], """\
#f1_in = File('f1.in')
#Command('f1.out', f1_in, Copy('$TARGET', '$SOURCE'))
-#open('f1.in', 'wb').write("f1.in\\n")
+#open('f1.in', 'wb').write(b"f1.in\\n")
f2_in = File('f2.in')
str(f2_in)
Command('f2.out', f2_in, Copy('$TARGET', '$SOURCE'))
-open('f2.in', 'wb').write("f2.in\\n")
+open('f2.in', 'wb').write(b"f2.in\\n")
""")
test.run(arguments = '--tree=all .')
diff --git a/test/VariantDir/errors.py b/test/VariantDir/errors.py
index d1490d4..256734e 100644
--- a/test/VariantDir/errors.py
+++ b/test/VariantDir/errors.py
@@ -77,7 +77,7 @@ env.Build('file.out', 'file.in')
# Just verify that the normal case works fine.
test.run(chdir = 'normal', arguments = ".")
-test.fail_test(test.read(['normal', 'build', 'file.out']) != "normal/src/file.in\n")
+test.fail_test(test.read(['normal', 'build', 'file.out']) != b"normal/src/file.in\n")
# Verify the error when the VariantDir itself is read-only. Don't bother
# to test this on Windows, because the ACL (I think) still allows the
diff --git a/test/explain/get_csig.py b/test/explain/get_csig.py
index d35a315..8a0266a 100644
--- a/test/explain/get_csig.py
+++ b/test/explain/get_csig.py
@@ -43,7 +43,7 @@ env = Environment()
def action( source, target, env ):
target[0].get_csig()
- f = open( str(target[0]), 'w' )
+ f = open( str(target[0]), 'wb' )
for s in source:
f.write( s.get_contents() )
f.close()
diff --git a/test/gnutools.py b/test/gnutools.py
index b0ebc1c..65d699b 100644
--- a/test/gnutools.py
+++ b/test/gnutools.py
@@ -49,11 +49,11 @@ cmd_opts, args = getopt.getopt(sys.argv[1:], 'f:s:co:', [])
output = None
opt_string = ''
for opt, arg in cmd_opts:
- if opt == '-o': output = open(arg, 'wb')
+ if opt == '-o': output = open(arg, 'w')
else: opt_string = opt_string + ' ' + opt + arg
output.write('gcc ' + opt_string + '\\n')
for a in args:
- contents = open(a, 'rb').read()
+ contents = open(a, 'r').read()
output.write(contents)
output.close()
sys.exit(0)
@@ -66,11 +66,11 @@ cmd_opts, args = getopt.getopt(sys.argv[1:], 'f:s:co:', [])
output = None
opt_string = ''
for opt, arg in cmd_opts:
- if opt == '-o': output = open(arg, 'wb')
+ if opt == '-o': output = open(arg, 'w')
else: opt_string = opt_string + ' ' + opt + arg
output.write('g++ ' + opt_string + '\\n')
for a in args:
- contents = open(a, 'rb').read()
+ contents = open(a, 'r').read()
output.write(contents)
output.close()
sys.exit(0)
@@ -116,31 +116,31 @@ test.run(chdir='work1')
def testObject(test, obj, expect):
contents = test.read(test.workpath('work1', obj))
- line1 = contents.split('\n')[0]
- actual = ' '.join(line1.split())
+ line1 = contents.split(b'\n')[0]
+ actual = b' '.join(line1.split())
if not expect == actual:
print("%s: %s != %s\n" % (obj, repr(expect), repr(actual)))
test.fail_test()
if sys.platform in ('win32', 'cygwin'):
- c_fpic = ''
+ c_fpic = b''
else:
- c_fpic = ' -fPIC'
-
-testObject(test, 'cfile1.o', 'gcc -c')
-testObject(test, 'cfile2.o', 'gcc -c')
-testObject(test, 'cppfile1.o', 'g++ -c')
-testObject(test, 'cppfile2.o', 'g++ -c')
-testObject(test, 'cfile1.os', 'gcc -c' + c_fpic)
-testObject(test, 'cfile2.os', 'gcc -c' + c_fpic)
-testObject(test, 'cppfile1.os', 'g++ -c' + c_fpic)
-testObject(test, 'cppfile2.os', 'g++ -c' + c_fpic)
-testObject(test, 'c-only' + _exe, 'gcc')
-testObject(test, 'cpp-only' + _exe, 'g++')
-testObject(test, 'c-and-cpp' + _exe, 'g++')
-testObject(test, dll('c-only'), 'gcc -shared')
-testObject(test, dll('cpp-only'), 'g++ -shared')
-testObject(test, dll('c-and-cpp'), 'g++ -shared')
+ c_fpic = b' -fPIC'
+
+testObject(test, 'cfile1.o', b'gcc -c')
+testObject(test, 'cfile2.o', b'gcc -c')
+testObject(test, 'cppfile1.o', b'g++ -c')
+testObject(test, 'cppfile2.o', b'g++ -c')
+testObject(test, 'cfile1.os', b'gcc -c' + c_fpic)
+testObject(test, 'cfile2.os', b'gcc -c' + c_fpic)
+testObject(test, 'cppfile1.os', b'g++ -c' + c_fpic)
+testObject(test, 'cppfile2.os', b'g++ -c' + c_fpic)
+testObject(test, 'c-only' + _exe, b'gcc')
+testObject(test, 'cpp-only' + _exe, b'g++')
+testObject(test, 'c-and-cpp' + _exe, b'g++')
+testObject(test, dll('c-only'), b'gcc -shared')
+testObject(test, dll('cpp-only'), b'g++ -shared')
+testObject(test, dll('c-and-cpp'), b'g++ -shared')
test.pass_test()