I am confused about the difference between two objects:
- the list of frames returned by
inspect.trace()while an exception is being handled - the traceback returned by
sys.exc_info()[2](or passed in the call tosys.excepthook)
Do the two objects contain the same information, just organized into a different data structure? If not, what one has that the other doesn’t?
From the documentation of inspect.trace:
which suggests that it provides a nice way to slice and dice which frames from
sys.exc_info()[2]you get.Which, if you look at the source:
(identical for 3.2 or 2.7), is exactly what it does, but it passes it through
getinnerframes, which annotates it with some useful information, per the docstring:And, since I’m curious about what that actually means:
Which, when called from the prompt, while recalling that many of those fields and objects have easy-to-find definitions:
(line numbers jumped around because I messed with formatting)
inspect.trace()is obviously a bit nicer.