From b010c4d37cfff5f74747d7da8cc1bf6719e29357 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Thu, 5 May 2011 19:07:21 -0700 Subject: bb.exceptions: handle tb entries without context Signed-off-by: Chris Larson --- lib/bb/exceptions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/bb/exceptions.py') diff --git a/lib/bb/exceptions.py b/lib/bb/exceptions.py index e134ae136..86621d24b 100644 --- a/lib/bb/exceptions.py +++ b/lib/bb/exceptions.py @@ -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: -- cgit 1.2.3-korg