diff options
author | Chris Larson <chris_larson@mentor.com> | 2011-05-13 17:35:37 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-06-08 20:38:24 +0100 |
commit | 2cf67a71e38bca2a2bf8f20c5143a006afb40276 (patch) | |
tree | da4016f7042d97e2a676a4e3cf23a04be24da035 /bitbake | |
parent | 63d14f474d52430f19653ef7ed881cd8dbaf3f42 (diff) | |
download | poky-2cf67a71e38bca2a2bf8f20c5143a006afb40276.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)
(Bitbake rev: dbf405f1f7fda41944093906c13044c6cf78f859)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/exceptions.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/bitbake/lib/bb/exceptions.py b/bitbake/lib/bb/exceptions.py index 86621d24ba..62d62cd4d8 100644 --- a/bitbake/lib/bb/exceptions.py +++ b/bitbake/lib/bb/exceptions.py | |||
@@ -29,13 +29,30 @@ class TracebackEntry(namedtuple.abc): | |||
29 | def __str__(self): | 29 | def __str__(self): |
30 | return ''.join(self.format()) | 30 | return ''.join(self.format()) |
31 | 31 | ||
32 | def _get_frame_args(frame): | ||
33 | """Get the formatted arguments and class (if available) for a frame""" | ||
34 | arginfo = inspect.getargvalues(frame) | ||
35 | firstarg = arginfo.args[0] | ||
36 | if firstarg == 'self': | ||
37 | self = arginfo.locals['self'] | ||
38 | cls = self.__class__.__name__ | ||
39 | |||
40 | arginfo.args.pop(0) | ||
41 | del arginfo.locals['self'] | ||
42 | else: | ||
43 | cls = None | ||
44 | |||
45 | formatted = inspect.formatargvalues(*arginfo) | ||
46 | return formatted, cls | ||
32 | 47 | ||
33 | def extract_traceback(tb, context=1): | 48 | def extract_traceback(tb, context=1): |
34 | frames = inspect.getinnerframes(tb, context) | 49 | frames = inspect.getinnerframes(tb, context) |
35 | for frame, filename, lineno, function, code_context, index in frames: | 50 | for frame, filename, lineno, function, code_context, index in frames: |
36 | args = inspect.formatargvalues(*inspect.getargvalues(frame)) | 51 | formatted_args, cls = _get_frame_args(frame) |
37 | yield TracebackEntry(filename, lineno, function, args, code_context, index) | 52 | if cls: |
38 | 53 | function = '%s.%s' % (cls, function) | |
54 | yield TracebackEntry(filename, lineno, function, formatted_args, | ||
55 | code_context, index) | ||
39 | 56 | ||
40 | def format_extracted(extracted, formatter=None, limit=None): | 57 | def format_extracted(extracted, formatter=None, limit=None): |
41 | if limit: | 58 | if limit: |