summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons
diff options
context:
space:
mode:
authorMathew Robinson <chasinglogic@gmail.com>2019-12-23 15:05:36 (GMT)
committerMathew Robinson <chasinglogic@gmail.com>2019-12-23 18:57:07 (GMT)
commitd88e0e7b976c2f9e261f03189441ab6af4c37de3 (patch)
tree31c0e528c3634f908c6d719437c1b83e80612ece /src/engine/SCons
parent5a864bae1380155997f4041d607e4abcf74652ca (diff)
downloadSCons-d88e0e7b976c2f9e261f03189441ab6af4c37de3.zip
SCons-d88e0e7b976c2f9e261f03189441ab6af4c37de3.tar.gz
SCons-d88e0e7b976c2f9e261f03189441ab6af4c37de3.tar.bz2
Prevent unnecessary eval calls in Subst
Diffstat (limited to 'src/engine/SCons')
-rw-r--r--src/engine/SCons/Subst.py70
1 files changed, 38 insertions, 32 deletions
diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py
index f3693a1..2e469ce 100644
--- a/src/engine/SCons/Subst.py
+++ b/src/engine/SCons/Subst.py
@@ -375,23 +375,26 @@ class StringSubber(object):
if key[0] == '{' or '.' in key:
if key[0] == '{':
key = key[1:-1]
- try:
- s = eval(key, self.gvars, lvars)
- except KeyboardInterrupt:
- raise
- except Exception as e:
- if e.__class__ in AllowableExceptions:
- return ''
- raise_exception(e, lvars['TARGETS'], s)
+
+ s = None
+ if key in lvars:
+ s = lvars[key]
+ elif key in self.gvars:
+ s = self.gvars[key]
else:
- if key in lvars:
- s = lvars[key]
- elif key in self.gvars:
- s = self.gvars[key]
- elif NameError not in AllowableExceptions:
- raise_exception(NameError(key), lvars['TARGETS'], s)
- else:
- return ''
+ try:
+ s = eval(key, self.gvars, lvars)
+ except KeyboardInterrupt:
+ raise
+ except Exception as e:
+ if e.__class__ in AllowableExceptions:
+ return ''
+ raise_exception(e, lvars['TARGETS'], s)
+
+ if s is None and NameError not in AllowableExceptions:
+ raise_exception(NameError(key), lvars['TARGETS'], s)
+ elif s is None:
+ return ''
# Before re-expanding the result, handle
# recursive expansion by copying the local
@@ -524,23 +527,26 @@ class ListSubber(collections.UserList):
if key[0] == '{' or key.find('.') >= 0:
if key[0] == '{':
key = key[1:-1]
- try:
- s = eval(key, self.gvars, lvars)
- except KeyboardInterrupt:
- raise
- except Exception as e:
- if e.__class__ in AllowableExceptions:
- return
- raise_exception(e, lvars['TARGETS'], s)
+
+ s = None
+ if key in lvars:
+ s = lvars[key]
+ elif key in self.gvars:
+ s = self.gvars[key]
else:
- if key in lvars:
- s = lvars[key]
- elif key in self.gvars:
- s = self.gvars[key]
- elif NameError not in AllowableExceptions:
- raise_exception(NameError(), lvars['TARGETS'], s)
- else:
- return
+ try:
+ s = eval(key, self.gvars, lvars)
+ except KeyboardInterrupt:
+ raise
+ except Exception as e:
+ if e.__class__ in AllowableExceptions:
+ return
+ raise_exception(e, lvars['TARGETS'], s)
+
+ if s is None and NameError not in AllowableExceptions:
+ raise_exception(NameError(), lvars['TARGETS'], s)
+ elif s is None:
+ return
# Before re-expanding the result, handle
# recursive expansion by copying the local