From the viewpoint of IDLE and masking, the stdlib has three parts: idlelib, other modules that IDLE imports, and other modules that IDLE does not import. As I already noted, this division is different for IDLE and user processes.
IDLE may delay importing some idlelib modules, and I intend to do this more if possible. But I am not going to worry about someone creating an idlelib directory with duplicate names. If someone does this, too bad.
Modules that IDLE does not import are not a concern for the operation of IDLE. If a *user* program masks an stdlib module that the program intends to import, it is not IDLE's direct concern.
This issue is about other modules that IDLE *does* import -- directly *or* indirectly. IDLE does not import 'random' -- the word does not appear in idlelib. On the other hand, in 3.6.1,
>>> import sys
>>> 'random' in sys.modules
True
For a user random.py to block IDLE startup, it must be that some module that imports it accesses some attribute during import, possibly as part of a 'from' import.
In order to make new code unit-testable, it should be put in a new 'fix_path' function, with a detailed specification. |