[issue17911] traceback: add a new thin class storing a traceback without storing local variables

Robert Collins report at bugs.python.org
Mon Jan 12 23:53:15 CET 2015


Robert Collins added the comment:

w.r.t. a new linecache interface, it looks like we need two attributes from f_globals: __name__ and __loader__, so that we can eventually call __loader__.get_source(__name__).

One small change (to let me focus on traceback) would be to add another kw argument  to the existing calls that take module_globals, called e.g. get_source, which would be a simple callable (source = get_source()). For the deferred linecache situation, we'd then create partial(f_globals.__loader__.get_source, f_globals.__name__) and keep that around until we need the source. We could even abstract that out into a function in linecache to keep the knowledge in one place.

Another way to tackle this would be to add a new function to linecache that lazily seeds the cache: it would stash the get_source method and the name against the filename, and when getline[s] is called actually invoke it.

I think the second way is a bit nicer myself. What do folk think?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17911>
_______________________________________


More information about the Python-bugs-list mailing list