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 rbcollins
Recipients adaptivelogic, eric.snow, gvanrossum, ncoghlan, pitrou, rbcollins, rhettinger, vstinner, yselivanov
Date 2015-01-12.22:53:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1421103195.13.0.61617127293.issue17911@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2015-01-12 22:53:15rbcollinssetrecipients: + rbcollins, gvanrossum, rhettinger, ncoghlan, pitrou, vstinner, eric.snow, yselivanov, adaptivelogic
2015-01-12 22:53:15rbcollinssetmessageid: <1421103195.13.0.61617127293.issue17911@psf.upfronthosting.co.za>
2015-01-12 22:53:15rbcollinslinkissue17911 messages
2015-01-12 22:53:14rbcollinscreate