summaryrefslogtreecommitdiffstats
path: root/SConstruct
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 /SConstruct
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 'SConstruct')
-rw-r--r--SConstruct21
1 files changed, 11 insertions, 10 deletions
diff --git a/SConstruct b/SConstruct
index 590aedf..dc9ee5d 100644
--- a/SConstruct
+++ b/SConstruct
@@ -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: