summaryrefslogtreecommitdiffstats
path: root/test/YACC
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-03-31 13:01:00 (GMT)
committerMats Wichmann <mats@linux.com>2019-04-25 15:37:04 (GMT)
commitf61d3bcd112285644c1a6ce253b267ef690a7e06 (patch)
tree2e489e238c11697f602cb9a7cbeb43afed088734 /test/YACC
parentb0c3385604ebc1d7d552472f1cc6d0910aafa32a (diff)
downloadSCons-f61d3bcd112285644c1a6ce253b267ef690a7e06.zip
SCons-f61d3bcd112285644c1a6ce253b267ef690a7e06.tar.gz
SCons-f61d3bcd112285644c1a6ce253b267ef690a7e06.tar.bz2
[PY 3.8] test fixes for file closings, rawstrings
On a linux host (missing some things that may be on the Travis CI setup), Py3.8a3 now shows 19 fails, 1048 pass, with 84 Warning: messages. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test/YACC')
-rw-r--r--test/YACC/YACC-fixture/myyacc.py12
-rw-r--r--test/YACC/YACCFLAGS-fixture/myyacc.py16
-rw-r--r--test/YACC/YACCHFILESUFFIX.py9
-rw-r--r--test/YACC/YACCHXXFILESUFFIX.py9
-rw-r--r--test/YACC/YACCVCGFILESUFFIX.py9
5 files changed, 29 insertions, 26 deletions
diff --git a/test/YACC/YACC-fixture/myyacc.py b/test/YACC/YACC-fixture/myyacc.py
index 756c98f..d0ab95e 100644
--- a/test/YACC/YACC-fixture/myyacc.py
+++ b/test/YACC/YACC-fixture/myyacc.py
@@ -1,13 +1,13 @@
import getopt
import sys
cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:', [])
-output = None
opt_string = ''
for opt, arg in cmd_opts:
- if opt == '-o': output = open(arg, 'w')
+ if opt == '-o': out = arg
else: opt_string = opt_string + ' ' + opt
-for a in args:
- contents = open(a, 'r').read()
- output.write(contents.replace('YACC', 'myyacc.py'))
-output.close()
+with open(out, 'w') as ofp:
+ for a in args:
+ with open(a, 'r') as ifp:
+ contents = ifp.read()
+ ofp.write(contents.replace('YACC', 'myyacc.py'))
sys.exit(0)
diff --git a/test/YACC/YACCFLAGS-fixture/myyacc.py b/test/YACC/YACCFLAGS-fixture/myyacc.py
index ffd9031..43024f1 100644
--- a/test/YACC/YACCFLAGS-fixture/myyacc.py
+++ b/test/YACC/YACCFLAGS-fixture/myyacc.py
@@ -1,17 +1,17 @@
import getopt
import sys
cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:I:x', [])
-output = None
opt_string = ''
i_arguments = ''
for opt, arg in cmd_opts:
- if opt == '-o': output = open(arg, 'wb')
+ if opt == '-o': out = arg
elif opt == '-I': i_arguments = i_arguments + ' ' + arg
else: opt_string = opt_string + ' ' + opt
-for a in args:
- contents = open(a, 'rb').read()
- contents = contents.replace(b'YACCFLAGS', opt_string.encode())
- contents = contents.replace(b'I_ARGS', i_arguments.encode())
- output.write(contents)
-output.close()
+with open(out, 'wb') as ofp:
+ for a in args:
+ with open(a, 'rb') as ifp:
+ contents = ifp.read()
+ contents = contents.replace(b'YACCFLAGS', opt_string.encode())
+ contents = contents.replace(b'I_ARGS', i_arguments.encode())
+ ofp.write(contents)
sys.exit(0)
diff --git a/test/YACC/YACCHFILESUFFIX.py b/test/YACC/YACCHFILESUFFIX.py
index f205473..6c34db1 100644
--- a/test/YACC/YACCHFILESUFFIX.py
+++ b/test/YACC/YACCHFILESUFFIX.py
@@ -46,12 +46,13 @@ for o, a in opts:
if o == '-o':
outfile = open(a, 'wb')
for f in args:
- infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
- outfile.write(l)
+ with open(f, 'rb') as infile:
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
+ outfile.write(l)
outfile.close()
base, ext = os.path.splitext(args[0])
-open(base+'.hsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode())
+with open(base+'.hsuffix', 'wb') as outfile:
+ outfile.write((" ".join(sys.argv) + '\\n').encode())
sys.exit(0)
""")
diff --git a/test/YACC/YACCHXXFILESUFFIX.py b/test/YACC/YACCHXXFILESUFFIX.py
index 6418189..63a5358 100644
--- a/test/YACC/YACCHXXFILESUFFIX.py
+++ b/test/YACC/YACCHXXFILESUFFIX.py
@@ -46,12 +46,13 @@ for o, a in opts:
if o == '-o':
outfile = open(a, 'wb')
for f in args:
- infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
- outfile.write(l)
+ with open(f, 'rb') as infile:
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
+ outfile.write(l)
outfile.close()
base, ext = os.path.splitext(args[0])
-open(base+'.hxxsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode())
+with open(base+'.hxxsuffix', 'wb') as outfile:
+ outfile.write((" ".join(sys.argv)+'\\n').encode())
sys.exit(0)
""")
diff --git a/test/YACC/YACCVCGFILESUFFIX.py b/test/YACC/YACCVCGFILESUFFIX.py
index 5306076..aee3265 100644
--- a/test/YACC/YACCVCGFILESUFFIX.py
+++ b/test/YACC/YACCVCGFILESUFFIX.py
@@ -48,13 +48,14 @@ for o, a in opts:
elif o == '-o':
outfile = open(a, 'wb')
for f in args:
- infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
- outfile.write(l)
+ with open(f, 'rb') as infile:
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
+ outfile.write(l)
outfile.close()
if vcg:
base, ext = os.path.splitext(args[0])
- open(base+'.vcgsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode())
+ with open(base+'.vcgsuffix', 'wb') as outfile:
+ outfile.write((" ".join(sys.argv)+'\\n').encode())
sys.exit(0)
""")