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 paul.moore
Recipients erik.bray, jdemeyer, paul.moore
Date 2018-04-30.17:42:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1525110129.96.0.682650639539.issue32797@psf.upfronthosting.co.za>
In-reply-to
Content
As I noted on python-ideas, continuing to search along sys.path if the loader returns None seems to match what the linecache docs say. If the issue had been phrased as "the implementation of linecache doesn't follow the docs" then I'd say fine, that's a reasonable report of something that we should fix.

But Erik's points are valid - the fact that the documentation describes a certain behaviour doesn't mean that it can't be wrong - and the fact that no-one else has flagged up the discrepancy before now implies that it's a relatively rare case.

IMO, debating whether a None return means there's absolutely no chance of there being source is silly - the best the loader can say is that it can't provide source. But that doesn't prove anything.

On the other hand, what is Cython source code even doing on sys.path? The whole discussion here seems to be based on the premise that extension modules (machine code) will be shipped with source code that will get installed alongside the binary. That's not the case for C extensions, but appears to be for Cython. I sort of understand the benefit, but it does seem to be a practice peculiar to one scenario, and I'm not sure the standard library should deal with it. (There's a performance cost to that path search, and I'm struggling to see how a Python programmer would benefit from access to the source code of a compiled extension anyway).

So I think that *either* we should fix the docs to be clearer that the path search is only done if the loader is not present or returns None, *or* we should implement the path search when the loader returns None. But I don't see that there's a strong argument here yet for changing the code - after all, it appears that the current behaviour has been round since Python 3.3, so it's not exactly an urgent issue. And unless someone is arguing that the change get backported, Cython still needs to work around the issue for users of older Pythons.
History
Date User Action Args
2018-04-30 17:42:10paul.mooresetrecipients: + paul.moore, erik.bray, jdemeyer
2018-04-30 17:42:09paul.mooresetmessageid: <1525110129.96.0.682650639539.issue32797@psf.upfronthosting.co.za>
2018-04-30 17:42:09paul.moorelinkissue32797 messages
2018-04-30 17:42:09paul.moorecreate