I'm pretty sure this code is wrong:

cwd = os.getcwd()
if not (cwd == os.path.dirname(os.__file__))):
    sys.path.remove(cwd)

I think you want:

cwd = os.getcwd()
if not (cwd == os.path.dirname(__file__))):
    sys.path.remove(cwd)

I'm don't understand why you would want the path to the 'os' module.

This does introduce some edge cases, like doing:

./bzr selftest

When in a directory that has a symlink in its path. I suppose you could
do:

cwd = os.path.realpath(os.getcwd())
if os.path.realpath(os.path.dirname(__file__) != cwd:

to handle symlinks.

You also should be using "os.getcwdu()" on Windows in case one of the
path segments has characters that aren't valid in your current codepage.
Since otherwise you get "????" paths. I'm *not* sure what something like
os.path.realpath() would do in that case, but there isn't really any
reason that we should fail because of it. (Similarly, we should probably
be using os.getcwd() on other systems, because you may be in a directory
structure that isn't valid in your current fs encoding. os.getcwdu()
will fail if it can't decode all the parts of the path.)


I'll note that the *actual* bug is in the specific site's default search path. 
Which hints towards an install issue outside of bzr's control. I would guess 
that adding something like this is a reasonable workaround for broken installs 
(as they seem to be fairly common), I just caution that applying a bandaid can 
introduce bugs at the same time.

-- 
should avoid loading modules from working directory
https://bugs.launchpad.net/bugs/72227
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to