Björn Sandberg Lynch added the comment:
I've been looking into this as an easy piece to bite off. If I understand Guido
correctly, he'd like to defer or suppress the linecache call when getting the
tb summary. The problem with deferring is that you need to access f_globals for
the loader to work correctly when the module source is a non-file import
source. If we keep a reference to f_globals for each line in the traceback, we
can defer this to later (ideally we'd just keep the __loader__ value, but that
would require changing the linecache interface as well).
My inclination would be to have another keyword argument to
_extract_tb_or_stack_iter (terse=False or verbose=True - either style works).
In terse mode, no source lines would be available, and the formatted output
would be the same as if the source wasn't available at all. This would work,
although the traceback module is structured so that I'd need to pass it through
quite a few wrapped iterator calls.
I'm not sure how free a hand I have when it comes to refactoring the internal
implementation. I'm not fond of the extractor callbacks - I'd prefer a
generator-based approach on the lines of:
def _tb_iter(tb, limit):
i = 0
while tb is not None:
if limit is not None and limit < i:
break
yield tb.tb_frame, tb.tb_lineno
tb = tb.tb_next
i += 1
def _extract_frame_iter(frames, terse=False):
...
for frame, lineno in frames:
...
----------
nosy: +adaptivelogic
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue17911>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com