diff options
Diffstat (limited to 'bitbake/lib/bb/event.py')
-rw-r--r-- | bitbake/lib/bb/event.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index bd2b0a4b05..5ffe89eae3 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
@@ -31,6 +31,7 @@ except ImportError: | |||
31 | import logging | 31 | import logging |
32 | import atexit | 32 | import atexit |
33 | import traceback | 33 | import traceback |
34 | import ast | ||
34 | import bb.utils | 35 | import bb.utils |
35 | import bb.compat | 36 | import bb.compat |
36 | import bb.exceptions | 37 | import bb.exceptions |
@@ -189,13 +190,15 @@ def register(name, handler, mask=None, filename=None, lineno=None): | |||
189 | if isinstance(handler, basestring): | 190 | if isinstance(handler, basestring): |
190 | tmp = "def %s(e):\n%s" % (name, handler) | 191 | tmp = "def %s(e):\n%s" % (name, handler) |
191 | try: | 192 | try: |
192 | import ast | 193 | code = bb.methodpool.compile_cache(tmp) |
193 | if filename is None: | 194 | if not code: |
194 | filename = "%s(e)" % name | 195 | if filename is None: |
195 | code = compile(tmp, filename, "exec", ast.PyCF_ONLY_AST) | 196 | filename = "%s(e)" % name |
196 | if lineno is not None: | 197 | code = compile(tmp, filename, "exec", ast.PyCF_ONLY_AST) |
197 | ast.increment_lineno(code, lineno-1) | 198 | if lineno is not None: |
198 | code = compile(code, filename, "exec") | 199 | ast.increment_lineno(code, lineno-1) |
200 | code = compile(code, filename, "exec") | ||
201 | bb.methodpool.compile_cache_add(tmp, code) | ||
199 | except SyntaxError: | 202 | except SyntaxError: |
200 | logger.error("Unable to register event handler '%s':\n%s", name, | 203 | logger.error("Unable to register event handler '%s':\n%s", name, |
201 | ''.join(traceback.format_exc(limit=0))) | 204 | ''.join(traceback.format_exc(limit=0))) |