summaryrefslogtreecommitdiff
path: root/bitbake
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-03-30 16:21:23 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-07-02 15:41:31 +0100
commitd8c8612d92fd243d395c97285f8c9b5d80a93b45 (patch)
treef3d3a1f7c6f030c9856ee6b3ef7f82b14e7db40e /bitbake
parentf8a8ec5ceb4b5f7a03e4a0024e5fe06ec8e7ad0a (diff)
downloadopenembedded-core-d8c8612d92fd243d395c97285f8c9b5d80a93b45.tar.gz
openembedded-core-d8c8612d92fd243d395c97285f8c9b5d80a93b45.tar.bz2
openembedded-core-d8c8612d92fd243d395c97285f8c9b5d80a93b45.zip
Two minor changes to the way python snippet expansion happens
- Use a single dictionary for the context, both global & local, since for some reason it chokes wanting a global "d" rather than a local in the metadata. - First compile the string into a code object before running eval, so we can include the variable name in an evaluation error. (Bitbake rev: 49534d928a37e0804ca84eed186cd22363023b2e) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/data_smart.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index 9067d54bfa..54ed72823b 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -39,11 +39,6 @@ __setvar_keyword__ = ["_append","_prepend"]
__setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?')
__expand_var_regexp__ = re.compile(r"\${[^{}]+}")
__expand_python_regexp__ = re.compile(r"\${@.+?}")
-_expand_globals = {
- "os": os,
- "bb": bb,
- "time": time,
-}
class DataSmart:
@@ -55,7 +50,12 @@ class DataSmart:
self._seen_overrides = seen
self.expand_cache = {}
- self.expand_locals = {"d": self}
+ self.expand_context = {
+ "os": os,
+ "bb": bb,
+ "time": time,
+ "d": self
+ }
def expand(self,s, varname):
def var_sub(match):
@@ -70,9 +70,9 @@ class DataSmart:
return match.group()
def python_sub(match):
- import bb
code = match.group()[3:-1]
- s = eval(code, _expand_globals, self.expand_locals)
+ codeobj = compile(code.strip(), varname or "<expansion>", "eval")
+ s = eval(codeobj, self.expand_context)
if type(s) == types.IntType: s = str(s)
return s