[Python-ideas] __loader__.get_source(): semantics of returning None
Jeroen Demeyer
J.Demeyer at UGent.be
Sat Apr 28 13:20:01 EDT 2018
On 2018-04-28 18:26, Paul Moore wrote:
> """
> If a file named filename is not found, the function will look for it
> in the module search path, sys.path, after first checking for a PEP
> 302 __loader__ in module_globals, in case the module was imported from
> a zipfile or other non-filesystem import source.
> """
Sorry, I should have been more precise. linecache does the following
(which is what is in the doc you quoted above):
(1) Look for the filename exactly as given.
(2) Look for a loader and call its get_source() method.
(3) Look for the filename under all sys.path entries.
The difference between (1) and (3) is when a relative filename is given,
typically relative to site-packages. And I'm actually interested in that
third case.
So the question is really: should (3) still be tried if
__loader__.get_source() returns None?
Jeroen.
More information about the Python-ideas
mailing list