summaryrefslogtreecommitdiffstats
path: root/bitbake
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
parent37cb4cc02b2e2b6c338c5943747e0a1ef15176b3 (diff)
downloadpoky-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')
-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 ec6446d64c..9e64fe5c42 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -150,6 +150,7 @@ def fire_from_worker(event, d):
150 event = pickle.loads(event[7:-8]) 150 event = pickle.loads(event[7:-8])
151 fire_ui_handlers(event, d) 151 fire_ui_handlers(event, d)
152 152
153noop = lambda _: None
153def register(name, handler): 154def register(name, handler):
154 """Register an Event handler""" 155 """Register an Event handler"""
155 156
@@ -161,10 +162,15 @@ def register(name, handler):
161 # handle string containing python code 162 # handle string containing python code
162 if isinstance(handler, basestring): 163 if isinstance(handler, basestring):
163 tmp = "def %s(e):\n%s" % (name, handler) 164 tmp = "def %s(e):\n%s" % (name, handler)
164 comp = bb.utils.better_compile(tmp, "%s(e)" % name, 165 try:
165 "bb.event._registerCode") 166 code = compile(tmp, "%s(e)" % name, "exec")
167 except SyntaxError:
168 logger.error("Unable to register event handler '%s':\n%s", name,
169 ''.join(traceback.format_exc(limit=0)))
170 _handlers[name] = noop
171 return
166 env = {} 172 env = {}
167 bb.utils.simple_exec(comp, env) 173 bb.utils.simple_exec(code, env)
168 func = bb.utils.better_eval(name, env) 174 func = bb.utils.better_eval(name, env)
169 _handlers[name] = func 175 _handlers[name] = func
170 else: 176 else: