diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 16 |
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"] | |||
39 | __setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?') | 39 | __setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?') |
40 | __expand_var_regexp__ = re.compile(r"\${[^{}]+}") | 40 | __expand_var_regexp__ = re.compile(r"\${[^{}]+}") |
41 | __expand_python_regexp__ = re.compile(r"\${@.+?}") | 41 | __expand_python_regexp__ = re.compile(r"\${@.+?}") |
42 | _expand_globals = { | ||
43 | "os": os, | ||
44 | "bb": bb, | ||
45 | "time": time, | ||
46 | } | ||
47 | 42 | ||
48 | 43 | ||
49 | class DataSmart: | 44 | class DataSmart: |
@@ -55,7 +50,12 @@ class DataSmart: | |||
55 | self._seen_overrides = seen | 50 | self._seen_overrides = seen |
56 | 51 | ||
57 | self.expand_cache = {} | 52 | self.expand_cache = {} |
58 | self.expand_locals = {"d": self} | 53 | self.expand_context = { |
54 | "os": os, | ||
55 | "bb": bb, | ||
56 | "time": time, | ||
57 | "d": self | ||
58 | } | ||
59 | 59 | ||
60 | def expand(self,s, varname): | 60 | def expand(self,s, varname): |
61 | def var_sub(match): | 61 | def var_sub(match): |
@@ -70,9 +70,9 @@ class DataSmart: | |||
70 | return match.group() | 70 | return match.group() |
71 | 71 | ||
72 | def python_sub(match): | 72 | def python_sub(match): |
73 | import bb | ||
74 | code = match.group()[3:-1] | 73 | code = match.group()[3:-1] |
75 | s = eval(code, _expand_globals, self.expand_locals) | 74 | codeobj = compile(code.strip(), varname or "<expansion>", "eval") |
75 | s = eval(codeobj, self.expand_context) | ||
76 | if type(s) == types.IntType: s = str(s) | 76 | if type(s) == types.IntType: s = str(s) |
77 | return s | 77 | return s |
78 | 78 | ||