[Distutils] [setuptools] Bug in setuptools ImpLoader

Phillip J. Eby pje at telecommunity.com
Fri Sep 8 21:16:07 CEST 2006


At 12:24 PM 9/8/2006 -0600, Jeremy Kloth wrote:
> >From PEP 302:
>
>   The load_module() method has a few responsibilities that it must
>     fulfill *before* it runs any code:
>
>     - If there is an existing module object named 'fullname' in
>       sys.modules, the loader *must* use that existing module.
>       (Otherwise, the reload() builtin will not work correctly.)
>       If a module named 'fullname' does not exist in sys.modules,
>       the loader must create a new module object and add it to
>       sys.modules.
>(emphasis on must)
>
>The current implementation always reloads the module if it exists.

Yes, that's the *intent* of the above paragraph.  An importer that 
*doesn't* reload under these circumstances will break the reload() builtin.


>   This
>problem exists in both the 0.6 and 0.7 series.  Since pkgutil is in Python
>2.5, this is an issue there as well.

Unless I've misunderstood you, this is not a problem, it's the correct and 
intended behavior.  When a loader is asked to load a module that's in 
sys.modules, it's supposed to *reload* it.  Otherwise, the reload() builtin 
won't work.



More information about the Distutils-SIG mailing list