[Python-Dev] is the 'path' argument to an importer's find_module() just a hint?

Brett Cannon brett at python.org
Mon Oct 27 21:26:06 CET 2008

On Mon, Oct 27, 2008 at 1:03 PM, Thomas Heller <theller at ctypes.org> wrote:
> Brett Cannon schrieb:
>> I just discovered frozen packages set their __path__ simply to their
>> name and not to a list as expected (http://bugs.python.org/issue4211).
>> This made me think about the 'path' argument to find_module() and
>> whether it can be treated as simply a hint or should always be
>> seriously looked at.
>> Take frozen modules, for instance. If the 'path' argument is meant to
>> always be considered then if a frozen module is within a package a
>> check should be done to make sure that the parent package is in 'path'
>> somewhere. But if it is simply a hint, then 'path' should be ignored
>> and whether the module can be found should depend fully on
>> imp.is_frozen().
>> So, what do people think? Should 'path' for find_module() always be
>> taken into consideration, or only when it happens to be convenient?
> At the moment I don't care about find_module for frozen modules/packages
> (is someone still using these?),

Beats me. At this point I am only implementing them for
backwards-compatibility, but they are exposing some inconsistencies in
how various aspects of import are implemented. If I had my way they
would be an optional thing that you would have to explicitly put on
sys.meta_path to avoid the overhead.

> but all the code I remember that
> manipulates a packages __path__ would most certainly break if it
> finds a string instead of a list.

Oh, definitely. That's why I filed the bug report on top of asking for
feedback on this.


More information about the Python-Dev mailing list