python imports from the current working directory on win32
This bug report was converted into a question: question #19011: python imports from the current working directory on win32.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Invalid
|
Low
|
Alexander Belchenko |
Bug Description
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(
Changed in bzr: | |
importance: | Untriaged → Low |
status: | Unconfirmed → Confirmed |
Changed in bzr: | |
assignee: | nobody → bialix |
milestone: | none → 1.0rc1 |
status: | Confirmed → In Progress |
Changed in bzr: | |
status: | In Progress → Fix Committed |
Changed in bzr: | |
assignee: | bialix → nobody |
status: | Fix Committed → Triaged |
Changed in bzr: | |
assignee: | nobody → bialix |
status: | Triaged → In Progress |
Attached patch seems to fix the bug for win32, but should be tested thoroughly.