summaryrefslogtreecommitdiffstats
path: root/lib/bb
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-05-13 17:35:37 -0700
committerChris Larson <chris_larson@mentor.com>2011-05-16 12:39:42 -0700
commitdbf405f1f7fda41944093906c13044c6cf78f859 (patch)
tree97868e62c8765f4a59dee0dfdae915ef2c21cb64 /lib/bb
parent0db267b94850053d02469d51d840d60ef96b6a43 (diff)
downloadbitbake-dbf405f1f7fda41944093906c13044c6cf78f859.tar.gz
bb.exceptions: don't show a repr of 'self'
Rather than treating self like an ordinary argument, showing a repr of its value in the function spec when formatting the traceback entry, now we show the class name for the method as a part of the function name. Example: Old: bar(self=<some repr of Fooclass>, f=5) New: Fooclass.bar(f=5) Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb')
-rw-r--r--lib/bb/exceptions.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/bb/exceptions.py b/lib/bb/exceptions.py
index 86621d24b..62d62cd4d 100644
--- a/lib/bb/exceptions.py
+++ b/lib/bb/exceptions.py
@@ -29,13 +29,30 @@ class TracebackEntry(namedtuple.abc):
def __str__(self):
return ''.join(self.format())
+def _get_frame_args(frame):
+ """Get the formatted arguments and class (if available) for a frame"""
+ arginfo = inspect.getargvalues(frame)
+ firstarg = arginfo.args[0]
+ if firstarg == 'self':
+ self = arginfo.locals['self']
+ cls = self.__class__.__name__
+
+ arginfo.args.pop(0)
+ del arginfo.locals['self']
+ else:
+ cls = None
+
+ formatted = inspect.formatargvalues(*arginfo)
+ return formatted, cls
def extract_traceback(tb, context=1):
frames = inspect.getinnerframes(tb, context)
for frame, filename, lineno, function, code_context, index in frames:
- args = inspect.formatargvalues(*inspect.getargvalues(frame))
- yield TracebackEntry(filename, lineno, function, args, code_context, index)
-
+ formatted_args, cls = _get_frame_args(frame)
+ if cls:
+ function = '%s.%s' % (cls, function)
+ yield TracebackEntry(filename, lineno, function, formatted_args,
+ code_context, index)
def format_extracted(extracted, formatter=None, limit=None):
if limit: