Comment 15 for bug 72227

Revision history for this message
Harald Meland (hmeland) wrote : Re: [Bug 72227] Re: should avoid loading modules from working directory

On Thu, Jul 16, 2009 at 2:36 PM, Forest Bond<email address hidden> wrote:
> Harald,
>
> I'm afraid what you're saying isn't adding up.  I can see from your test
> script that the CWD is in your sys.path.  That clearly indicates that
> modules in your CWD should get imported.

The _script directory_ is in my sys.path. When I run my test script
as "./test.py", the script directory and the CWD coincide. However,
as my bzr typically isn't run as "./bzr" when I'm in danger of
triggering this bug, the CWD will not be in my sys.path.

What I'm wondering is, does the test.py script, when run on your
system, indicate the absolute path to the script directory is in
sys.path, or is there an empty-string element in your sys.path? And,
if there is any empty-string elements there, is the script directory
there, as well? And finally, is the absolute path to the CWD somehow
included in your sys.path?

> Why don't you tell me what you're doing to reproduce, and I'll see if I
> can help you figure out what the problem is.

I performed the exact same steps that you indicated:

hmeland@octarine:/tmp/,72227$ touch logging.py
hmeland@octarine:/tmp/,72227$ bzr stat
unknown:
  logging.py

... and as you can see, I was unable to reproduce the bug in this way, too.

My thinking is that if the fix for this issue is as simple as removing
any empty-string elements from sys.path (on Python installations that
somehow isn't conforming to the sys.path documentation I linked to),
then that should be easy to fix.

If, on the other hand, your python somehow includes one or more
absolute path to directories that we don't really want to import
modules from, the fix might have to be more involved (one possible
remedy in this case might be to run Python with the -S command-line
option).
--
Harald