Message233895
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? |
|
Date |
User |
Action |
Args |
2015-01-12 22:53:15 | rbcollins | set | recipients:
+ rbcollins, gvanrossum, rhettinger, ncoghlan, pitrou, vstinner, eric.snow, yselivanov, adaptivelogic |
2015-01-12 22:53:15 | rbcollins | set | messageid: <1421103195.13.0.61617127293.issue17911@psf.upfronthosting.co.za> |
2015-01-12 22:53:15 | rbcollins | link | issue17911 messages |
2015-01-12 22:53:14 | rbcollins | create | |
|