[bitbake-devel] [PATCH 2/2] bb.cookerdata: include useful traceback for ExpansionError/ParseError

Christopher Larson kergoth at gmail.com
Mon Aug 24 22:32:00 UTC 2015


From: Christopher Larson <chris_larson at mentor.com>

Show the user only the portion of the traceback which was from the metadata,
nothing from bitbake's internal calls.

Signed-off-by: Christopher Larson <chris_larson at mentor.com>
---
 lib/bb/cookerdata.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/bb/cookerdata.py b/lib/bb/cookerdata.py
index 57fc6bb..a033266 100644
--- a/lib/bb/cookerdata.py
+++ b/lib/bb/cookerdata.py
@@ -179,7 +179,16 @@ def catch_parse_error(func):
             parselog.critical("Unable to parse %s: %s" % (fn, exc))
             sys.exit(1)
         except (bb.parse.ParseError, bb.data_smart.ExpansionError) as exc:
-            parselog.critical("Unable to parse %s: %s" % (fn, exc))
+            import traceback
+
+            bbdir = os.path.dirname(__file__) + os.sep
+            exc_class, exc, tb = sys.exc_info()
+            for tb in iter(lambda: tb.tb_next, None):
+                # Skip frames in bitbake itself, we only want the metadata
+                fn, _, _, _ = traceback.extract_tb(tb, 1)[0]
+                if not fn.startswith(bbdir):
+                    break
+            parselog.critical("Unable to parse %s", fn, exc_info=(exc_class, exc, tb))
             sys.exit(1)
     return wrapped
 
-- 
2.2.1




More information about the bitbake-devel mailing list