summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-04-04 13:51:51 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-06 15:48:34 +0100
commitfc801b907361cfdb7e329eefac7a0c991e86c736 (patch)
treee4188c0ca0637c667857a7a184356acb1ec7acc0 /bitbake/lib
parent37cb4cc02b2e2b6c338c5943747e0a1ef15176b3 (diff)
downloadast2050-yocto-poky-fc801b907361cfdb7e329eefac7a0c991e86c736.zip
ast2050-yocto-poky-fc801b907361cfdb7e329eefac7a0c991e86c736.tar.gz
event: improve output for syntax errors in handlers
Note: this includes IndentationError, which is a subclass of SyntaxError. (Bitbake rev: 156ea134e82d873ca4b5343261da2291a2b32ef6) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/event.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index ec6446d..9e64fe5 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -150,6 +150,7 @@ def fire_from_worker(event, d):
event = pickle.loads(event[7:-8])
fire_ui_handlers(event, d)
+noop = lambda _: None
def register(name, handler):
"""Register an Event handler"""
@@ -161,10 +162,15 @@ def register(name, handler):
# handle string containing python code
if isinstance(handler, basestring):
tmp = "def %s(e):\n%s" % (name, handler)
- comp = bb.utils.better_compile(tmp, "%s(e)" % name,
- "bb.event._registerCode")
+ try:
+ code = compile(tmp, "%s(e)" % name, "exec")
+ except SyntaxError:
+ logger.error("Unable to register event handler '%s':\n%s", name,
+ ''.join(traceback.format_exc(limit=0)))
+ _handlers[name] = noop
+ return
env = {}
- bb.utils.simple_exec(comp, env)
+ bb.utils.simple_exec(code, env)
func = bb.utils.better_eval(name, env)
_handlers[name] = func
else:
OpenPOWER on IntegriCloud