summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussel Winder <russel@winder.org.uk>2017-07-28 06:12:29 (GMT)
committerRussel Winder <russel@winder.org.uk>2017-07-28 06:12:29 (GMT)
commit653e1c27e6359388093ae707f55ec96f6c1faabf (patch)
treecc3b653516880f391a5f46b82ddca26695c51201
parent61a7c43e98602536f1eecdae1a46475a7a0ab734 (diff)
parenta13f1e3f721c4b5d65f0a942d184c300718d0d57 (diff)
downloadSCons-653e1c27e6359388093ae707f55ec96f6c1faabf.zip
SCons-653e1c27e6359388093ae707f55ec96f6c1faabf.tar.gz
SCons-653e1c27e6359388093ae707f55ec96f6c1faabf.tar.bz2
Merge mainline.
-rw-r--r--src/engine/SCons/Debug.py4
-rw-r--r--src/engine/SCons/Tool/linkloc.py4
-rw-r--r--src/engine/SCons/Util.py5
-rw-r--r--src/engine/SCons/Variables/__init__.py4
-rw-r--r--src/engine/SCons/cpp.py3
5 files changed, 12 insertions, 8 deletions
diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py
index 9e520ff..706b4c4 100644
--- a/src/engine/SCons/Debug.py
+++ b/src/engine/SCons/Debug.py
@@ -97,7 +97,8 @@ def dumpLoggedInstances(classes, file=sys.stdout):
if sys.platform[:5] == "linux":
# Linux doesn't actually support memory usage stats from getrusage().
def memory():
- mstr = open('/proc/self/stat').read()
+ with open('/proc/self/stat') as f:
+ mstr = f.read()
mstr = mstr.split()[22]
return int(mstr)
elif sys.platform[:6] == 'darwin':
@@ -233,6 +234,7 @@ def Trace(msg, file=None, mode='w', tstamp=None):
PreviousTime = now
fp.write(msg)
fp.flush()
+ fp.close()
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Tool/linkloc.py b/src/engine/SCons/Tool/linkloc.py
index bd643f7..c73852b 100644
--- a/src/engine/SCons/Tool/linkloc.py
+++ b/src/engine/SCons/Tool/linkloc.py
@@ -52,8 +52,8 @@ def repl_linker_command(m):
# Replaces any linker command file directives (e.g. "@foo.lnk") with
# the actual contents of the file.
try:
- f=open(m.group(2), "r")
- return m.group(1) + f.read()
+ with open(m.group(2), "r") as f:
+ return m.group(1) + f.read()
except IOError:
# the linker should return an error if it can't
# find the linker command file so we will remain quiet.
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 4d0df22..846d06c 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -1506,9 +1506,8 @@ def MD5signature(s):
def MD5filesignature(fname, chunksize=65536):
- f = open(fname, "rb")
- result = f.read()
- f.close()
+ with open(fname, "rb") as f:
+ result = f.read()
return result
try:
diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py
index cd66604..1fe4435 100644
--- a/src/engine/SCons/Variables/__init__.py
+++ b/src/engine/SCons/Variables/__init__.py
@@ -175,7 +175,9 @@ class Variables(object):
sys.path.insert(0, dir)
try:
values['__name__'] = filename
- exec(open(filename, 'r').read(), {}, values)
+ with open(filename, 'r') as f:
+ contents = f.read()
+ exec(contents, {}, values)
finally:
if dir:
del sys.path[0]
diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py
index f282ba7..2e20017 100644
--- a/src/engine/SCons/cpp.py
+++ b/src/engine/SCons/cpp.py
@@ -379,7 +379,8 @@ class PreProcessor(object):
return None
def read_file(self, file):
- return open(file).read()
+ with open(file) as f:
+ return f.read()
# Start and stop processing include lines.