]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bb.event: handle __builtins__ as a module
authorChristopher Larson <chris_larson@mentor.com>
Sat, 30 Apr 2016 19:43:53 +0000 (12:43 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 6 May 2016 09:18:06 +0000 (10:18 +0100)
Fixes pypy support.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/event.py

index 5ffe89eae3eeb563732ed558a3ee73f78506f051..5a03a31f4368d6f68512d95727a1d323ba255cef 100644 (file)
@@ -72,11 +72,16 @@ _catchall_handlers = {}
 _eventfilter = None
 _uiready = False
 
+if hasattr(__builtins__, '__setitem__'):
+    builtins = __builtins__
+else:
+    builtins = __builtins__.__dict__
+
 def execute_handler(name, handler, event, d):
     event.data = d
     addedd = False
-    if 'd' not in __builtins__:
-        __builtins__['d'] = d
+    if 'd' not in builtins:
+        builtins['d'] = d
         addedd = True
     try:
         ret = handler(event)
@@ -94,7 +99,7 @@ def execute_handler(name, handler, event, d):
     finally:
         del event.data
         if addedd:
-            del __builtins__['d']
+            del builtins['d']
 
 def fire_class_handlers(event, d):
     if isinstance(event, logging.LogRecord):