From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: bitbake-devel <bitbake-devel@lists.openembedded.org>
Cc: Chris Larson <clarson@kergoth.com>
Subject: [PATCH] event: Inject 'd' into event handlers
Date: Fri, 19 Jun 2015 09:27:14 +0100 [thread overview]
Message-ID: <1434702434.14710.106.camel@linuxfoundation.org> (raw)
To quote Chris Larson:
"""
e.data.getVar() gets a bit old in a large event handler, and it means a
simple handler has to be modified if switching between an event handler
(e.g. RecipeParsed) and anonymous python. I think it would make sense
to restore the 'd' convention here to align with python elsewhere.
It'd just be a convenience, d==e.data, to avoid the common pattern of
setting it at the top of the event handler.
"""
I couldn't find a way to inject 'd' via locals/globals due to the use
of a function parameter so this left __builtins__ as the only way
I could find to make this work.
[YOCTO #7668]
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index f755eb2..80e3796 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -72,6 +72,7 @@ _eventfilter = None
def execute_handler(name, handler, event, d):
event.data = d
+ __builtins__['d'] = d
try:
ret = handler(event)
except bb.parse.SkipRecipe:
@@ -87,6 +88,7 @@ def execute_handler(name, handler, event, d):
logger.error("Execution of event handler '%s' failed (exit code %s)" % (name, exc.code))
finally:
del event.data
+ del __builtins__['d']
def fire_class_handlers(event, d):
if isinstance(event, logging.LogRecord):
reply other threads:[~2015-06-19 8:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1434702434.14710.106.camel@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=bitbake-devel@lists.openembedded.org \
--cc=clarson@kergoth.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox