python imports from the current working directory on win32
This isn't really a bzr bug, but bzr runs into this bug with python. And this helps document what is going on.
With a default python installation and win32, the current working directory is always added to 'sys.path'. Even when running a script from another directory. (apparently this sometimes happens on freebsd as well)
It would seem that the default sys.path starts with:
[<dir of the script>, <dir of python24.zip>, '', ...]
Where '' is the empty string.
In 'site.py' the function 'removeduppaths' expands the empty string to the current working directory and updates sys.path.
According to 'cosmit' on IRC, python2.5 actually has '' happen *before* python25.zip. Which means files in the current working directory get imported before system files, even when running a script from another dir.
Either way, the current working directory should only be present in sys.path if the script is being run from the current directory.
It should be possible to change site.py to behave correctly by removing '' from the list of paths.
Note: this function runs *before* dirname(
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Bazaar Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
This question was originally filed as bug #53478.