summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/event.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/event.py')
-rw-r--r--bitbake/lib/bb/event.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index ec25ce77fb..bd2b0a4b05 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -177,7 +177,7 @@ def fire_from_worker(event, d):
177 fire_ui_handlers(event, d) 177 fire_ui_handlers(event, d)
178 178
179noop = lambda _: None 179noop = lambda _: None
180def register(name, handler, mask=None): 180def register(name, handler, mask=None, filename=None, lineno=None):
181 """Register an Event handler""" 181 """Register an Event handler"""
182 182
183 # already registered 183 # already registered
@@ -189,7 +189,13 @@ def register(name, handler, mask=None):
189 if isinstance(handler, basestring): 189 if isinstance(handler, basestring):
190 tmp = "def %s(e):\n%s" % (name, handler) 190 tmp = "def %s(e):\n%s" % (name, handler)
191 try: 191 try:
192 code = compile(tmp, "%s(e)" % name, "exec") 192 import ast
193 if filename is None:
194 filename = "%s(e)" % name
195 code = compile(tmp, filename, "exec", ast.PyCF_ONLY_AST)
196 if lineno is not None:
197 ast.increment_lineno(code, lineno-1)
198 code = compile(code, filename, "exec")
193 except SyntaxError: 199 except SyntaxError:
194 logger.error("Unable to register event handler '%s':\n%s", name, 200 logger.error("Unable to register event handler '%s':\n%s", name,
195 ''.join(traceback.format_exc(limit=0))) 201 ''.join(traceback.format_exc(limit=0)))