summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Script
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-03-06 21:00:01 (GMT)
committerMats Wichmann <mats@linux.com>2019-03-07 20:06:04 (GMT)
commit59622eef74a5a1c698ec71cbf2d48a308c07c1fa (patch)
treea9e8fe5c8468e25d2adaf9cd43b51523b7e34174 /src/engine/SCons/Script
parentf0f48202c59f8d00f47aaec25986d343e3c72ca4 (diff)
downloadSCons-59622eef74a5a1c698ec71cbf2d48a308c07c1fa.zip
SCons-59622eef74a5a1c698ec71cbf2d48a308c07c1fa.tar.gz
SCons-59622eef74a5a1c698ec71cbf2d48a308c07c1fa.tar.bz2
Clean up some file opens, regex strings
Most recent Python (3.8 alpha) spews warnings aplenty about two subjects: unclosed files and strings which look like they have embedded escapes that Python does not recognize. The latter are usually regexes, and it provides a reminder that regular expressions should normally be specified as raw strings, so Python does not attempt to interpret them. Irritating is that even docstrings are flagged, it's not obvious what the right answer is for a docstring which contains, say, a Windows-style path with backslashes. This converts a bunch of opens that are not closed into context manager usage and regex patterns into raw strings. This eliminate about 4000 warnings spewed by Py3.8 (9200 remain). Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'src/engine/SCons/Script')
-rw-r--r--src/engine/SCons/Script/SConscript.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 560402c..eabaddb 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -278,11 +278,12 @@ def _SConscript(fs, *files, **kw):
pass
try:
try:
-# _file_ = SCons.Util.to_str(_file_)
if Main.print_time:
time1 = time.time()
- exec(compile(_file_.read(), _file_.name, 'exec'),
- call_stack[-1].globals)
+ scriptdata = _file_.read()
+ scriptname = _file_.name
+ _file_.close()
+ exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
except SConscriptReturn:
pass
finally:
@@ -397,9 +398,9 @@ class SConsEnvironment(SCons.Environment.Base):
something like 3.2b1."""
version = version_string.split(' ')[0].split('.')
v_major = int(version[0])
- v_minor = int(re.match('\d+', version[1]).group())
+ v_minor = int(re.match(r'\d+', version[1]).group())
if len(version) >= 3:
- v_revision = int(re.match('\d+', version[2]).group())
+ v_revision = int(re.match(r'\d+', version[2]).group())
else:
v_revision = 0
return v_major, v_minor, v_revision