From: stevenknight Date: Fri, 22 Oct 2004 21:57:53 +0000 (+0000) Subject: Avoid copying __builtin__ when evaluating variables. (Gary Oberbrunner) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ce3186a7bfaf29569123215c77d1593561e9a72d;p=scons.git Avoid copying __builtin__ when evaluating variables. (Gary Oberbrunner) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1136 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 67472610..9845e85f 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -154,6 +154,9 @@ RELEASE 0.97 - XXX will not be added to the construction environment unless it's set explicitly by the user or from an Options file. + - Avoid copying __builtin__ values into a construction environment's + dictionary when evaluating construction variables. + From Chris Pawling: - Have the linkloc tool use $MSVS_VERSION to select the Microsoft diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 4e819350..b713b570 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -692,9 +692,22 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=No if gvars is None: gvars = env.Dictionary() + # We're (most likely) going to eval() things. If Python doesn't + # find a __builtin__ value in the global dictionary used for eval(), + # it copies the current __builtin__ values for you. Avoid this by + # setting it explicitly and then deleting, so we don't pollute the + # construction environment Dictionary(ies) that are typically used + # for expansion. + gvars['__builtin__'] = __builtin__ + ss = StringSubber(env, mode, target, source, conv, gvars) result = ss.substitute(strSubst, dict) + try: + del gvars['__builtin__'] + except KeyError: + pass + if is_String(result): # Remove $(-$) pairs and any stuff in between, # if that's appropriate. @@ -929,9 +942,22 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di if gvars is None: gvars = env.Dictionary() + # We're (most likely) going to eval() things. If Python doesn't + # find a __builtin__ value in the global dictionary used for eval(), + # it copies the current __builtin__ values for you. Avoid this by + # setting it explicitly and then deleting, so we don't pollute the + # construction environment Dictionary(ies) that are typically used + # for expansion. + gvars['__builtins__'] = __builtins__ + ls = ListSubber(env, mode, target, source, conv, gvars) ls.substitute(strSubst, dict, 0) + try: + del gvars['__builtins__'] + except KeyError: + pass + return ls.data def scons_subst_once(strSubst, env, key):