]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bb.exceptions: handle tb entries without context
authorChris Larson <chris_larson@mentor.com>
Fri, 6 May 2011 02:07:21 +0000 (19:07 -0700)
committerChris Larson <chris_larson@mentor.com>
Mon, 16 May 2011 19:39:41 +0000 (12:39 -0700)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/bb/exceptions.py

index e134ae136daa78c949d4806d6937a7932f31ee44..86621d24ba9f9ff34df9ae12395615d8bf686699 100644 (file)
@@ -8,10 +8,13 @@ from collections import namedtuple
 class TracebackEntry(namedtuple.abc):
     """Pickleable representation of a traceback entry"""
     _fields = 'filename lineno function args code_context index'
-    _header = '  File "{0.filename}", line {0.lineno}, in {0.function}{0.args}:\n'
+    _header = '  File "{0.filename}", line {0.lineno}, in {0.function}{0.args}'
 
     def format(self, formatter=None):
-        formatted = [self._header.format(self)]
+        if not self.code_context:
+            return self._header.format(self) + '\n'
+
+        formatted = [self._header.format(self) + ':\n']
 
         for lineindex, line in enumerate(self.code_context):
             if formatter: