Nick Coghlan added the comment:

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.

----------
nosy: +brett.cannon, eric.snow

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23809>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to