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 ncoghlan
Recipients brett.cannon, eric.snow, georg.brandl, larry, ncoghlan, rbcollins
Date 2015-03-30.01:14:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427678099.46.0.23014351688.issue23809@psf.upfronthosting.co.za>
In-reply-to
Content
I proposed limiting it to stdlib names as that's the case where we see the most beginner confusion (experimenting with sockets in a file named "socket.py", etc), and the one where we can generate a comprehensive list of known module names ahead of time (so in most cases we won't need to touch the filesystem to determine there's no shadowing happening once the list of stdlib modules has been pulled in to memory).

Handling the general case means we have to instead rely on rescanning the import system at runtime. On the other hand, we're already doing something along those lines through linecache to handle retrieving source lines, and the import system itself already has caches everywhere (hence importlib.invalidate_caches()), so adding yet-another-cache to be able to check for module shadowing efficiently wouldn't be that big a deal.

Adding Brett & Eric to get some additional perspectives on the idea of doing checks for name shadowing through a new importlib.util API rather than a separate stdlib specific mechanism.
History
Date User Action Args
2015-03-30 01:14:59ncoghlansetrecipients: + ncoghlan, brett.cannon, georg.brandl, larry, rbcollins, eric.snow
2015-03-30 01:14:59ncoghlansetmessageid: <1427678099.46.0.23014351688.issue23809@psf.upfronthosting.co.za>
2015-03-30 01:14:59ncoghlanlinkissue23809 messages
2015-03-30 01:14:58ncoghlancreate