Issue 18065: set path = [] for frozen packages (original) (raw)

If you import the frozen phello package, you will notice that phello.path == ['phello']. While that seems innocuous, that could potentially lead to incorrect results if there just so happens to be a directory named phello which contains a file that isn't a frozen submodule (i.e. FrozenImporter can't find the submodule but PathFinder can find a file that happens to match the module's name).

So for that reason I want to simply set path = [] for frozen packages. The language reference for import states setting path to anything makes a module a package and that it just needs to be an iterable that only returns strings (http://docs.python.org/3.4/reference/import.html#packages), so an empty list works. Plus package contains the same information so there is no lost data by doing this.

Can anyone think of a good reason not to do this? I can't see why someone would be relying upon this for any reason since the existence of path itself is enough to determine something is a package.