[mod_python] bug in apache.import_module

Graham Dumpleton grahamd at dscpl.com.au
Thu Apr 28 18:35:14 EDT 2005


See:

   http://issues.apache.org/jira/browse/MODPYTHON-9
   http://issues.apache.org/jira/browse/MODPYTHON-10
   http://issues.apache.org/jira/browse/MODPYTHON-11

There are various known issues with using same name module in different
directories.

The first one has been addressed for next version of mod_python.

Graham

On 29/04/2005, at 8:22 AM, Huzaifa Tapal wrote:

> I think there is a bug in apache.import_module.  I am using 
> apache.import_module passing in the path where I want the module 
> imported from.  I am seeing a very odd result as to sometimes, the 
> module that is loaded is not the right one.  Instead it loads a module 
> that is of the same name but in a different directory.  Here is what 
> is happening:
>
> I have two modules of same name in 2 different directories as follows;
>
> /home/user/dir1/moduleA
> /home/user/dir123/moduleB
>
> Lets say I restart apache and load up moduleA.  At that point there is 
> an entry in sys.modules for moduleA.  Lets say then, I load up 
> moduleB, now the original entry for moduleA is overwritten by this new 
> entry.  Now when I go back to load moduleA, I get back moduleB 
> results. Here is why:
>
> In apache.import_module if I pass in the path to load moduleA from 
> '/home/user/dir1' and the last module was in '/home/user/dir123' then 
> the check in import_module to make sure both modules aren't the same 
> fails since it does a "file.startswith()" check on the path.  Since 
> the path moduleA is in the path to moduleB, it loads the wrong module.
>
> I see that somebody else had complained about this problem in 
> mod_python 1.3.1 but it still has not been patched.
>
> Any ideas?
>
> Hozi
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list