This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author adaptivelogic
Recipients adaptivelogic, gvanrossum, ncoghlan, pitrou
Date 2013-07-08.17:04:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1373303074.41.0.663784733906.issue17911@psf.upfronthosting.co.za>
In-reply-to
Content
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:
    ...
History
Date User Action Args
2013-07-08 17:04:34adaptivelogicsetrecipients: + adaptivelogic, gvanrossum, ncoghlan, pitrou
2013-07-08 17:04:34adaptivelogicsetmessageid: <1373303074.41.0.663784733906.issue17911@psf.upfronthosting.co.za>
2013-07-08 17:04:34adaptivelogiclinkissue17911 messages
2013-07-08 17:04:34adaptivelogiccreate