Patchwork [bitbake-devel,2/2] cooker: fix handling of exceptions during exception handling

mail settings
Submitter Paul Eggleton
Date Sept. 7, 2012, 3:22 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/36131/
State New
Headers show


Paul Eggleton - Sept. 7, 2012, 3:22 p.m.
If an exception occurs during handling another exception we were
getting a useless traceback such as the following, after which
BitBake froze:

ERROR: Command execution failed: Traceback (most recent call last):
  File "/home/user/poky/poky/bitbake/lib/bb/", line 84, in runAsyncCommand
  File "/home/user/poky/poky/bitbake/lib/bb/", line 1207, in updateCache
    if not self.parser.parse_next():
  File "/home/user/poky/poky/bitbake/lib/bb/", line 1694, in parse_next
    logger.error('Unable to parse %s', value.recipe,
AttributeError: 'exceptions.TypeError' object has no attribute 'recipe'

Fix this to print an actual traceback of the exception and exit
gracefully (well, as gracefully as possible under the circumstances).

The general fix for [YOCTO #2977].

Signed-off-by: Paul Eggleton <>
 bitbake/lib/bb/ |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)


diff --git a/bitbake/lib/bb/ b/bitbake/lib/bb/
index 1b3bb84..19173ae 100644
--- a/bitbake/lib/bb/
+++ b/bitbake/lib/bb/
@@ -1691,8 +1691,13 @@  class CookerParser(object):
         except Exception as exc:
             self.error += 1
             etype, value, tb = sys.exc_info()
-            logger.error('Unable to parse %s', value.recipe,
-                         exc_info=(etype, value, exc.traceback))
+            if hasattr(value, "recipe"):
+                logger.error('Unable to parse %s', value.recipe,
+                            exc_info=(etype, value, exc.traceback))
+            else:
+                # Most likely, an exception occurred during raising an exception
+                import traceback
+                logger.error('Exception during parse: %s' % traceback.format_exc())
             return False