diff options
author | Mats Wichmann <mats@linux.com> | 2019-03-31 13:01:00 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2019-04-25 15:37:04 (GMT) |
commit | f61d3bcd112285644c1a6ce253b267ef690a7e06 (patch) | |
tree | 2e489e238c11697f602cb9a7cbeb43afed088734 /SConstruct | |
parent | b0c3385604ebc1d7d552472f1cc6d0910aafa32a (diff) | |
download | SCons-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 'SConstruct')
-rw-r--r-- | SConstruct | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -96,14 +96,16 @@ git_status_lines = [] if git: cmd = "%s ls-files 2> /dev/null" % git - git_status_lines = os.popen(cmd, "r").readlines() + with os.popen(cmd, "r") as p: + git_status_lines = p.readlines() revision = ARGUMENTS.get('REVISION', '') def generate_build_id(revision): return revision if not revision and git: - git_hash = os.popen("%s rev-parse HEAD 2> /dev/null" % git, "r").read().strip() + with os.popen("%s rev-parse HEAD 2> /dev/null" % git, "r") as p: + git_hash = p.read().strip() def generate_build_id(revision): result = git_hash if [l for l in git_status_lines if 'modified' in l]: @@ -570,10 +572,9 @@ for p in [ scons ]: def write_src_files(target, source, **kw): global src_files src_files.sort() - f = open(str(target[0]), 'w') - for file in src_files: - f.write(file + "\n") - f.close() + with open(str(target[0]), 'w') as f: + for file in src_files: + f.write(file + "\n") return 0 env.Command(os.path.join(build, 'MANIFEST'), MANIFEST_in_list, @@ -662,14 +663,14 @@ for p in [ scons ]: def Digestify(target, source, env): import hashlib src = source[0].rfile() - contents = open(str(src),'rb').read() + with open(str(src),'rb') as f: + contents = f.read() m = hashlib.md5() m.update(contents) sig = m.hexdigest() bytes = os.stat(str(src))[6] - open(str(target[0]), 'w').write("MD5 %s %s %d\n" % (sig, - src.name, - bytes)) + with open(str(target[0]), 'w') as f: + f.write("MD5 %s %s %d\n" % (sig, src.name, bytes)) env.Command(digest, tar_gz, Digestify) if not zipit: |