[MERGE][1.0] disable python imports from cwd (problem with python2.4 @ win32: bug #53478)

Alexander Belchenko bialix at ukr.net
Sat Nov 24 15:42:08 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aaron Bentley пишет:
> Alexander Belchenko wrote:
>> This patch fixes problem with python 2.4 that annoys me for years:
> 
>> if I have bzr installed for my Python (i.e. in site-packages) and
>> I cd to bzr sources directory, then running system-wide bzr I constantly
>> have problems because bzr try to import bzrlib from current directory
>> first, not from site-packages.
> 
>> Proposed patch fixes all possible variants and works with 2.4 and 2.5.
>> In my strong opinion we should not manipulate with sys.path in bzrlib itself,
>> only in bzr script. Therefore I did only manual testing.
> 
> I would think that run_bzr_subprocess could be used to test this.

And provide some fake bzrlib in temp dir? It's doable.

>> +if os.getcwd() in sys.path[1:]:     # skip first item
>> +    sys.path.pop(sys.path.index(os.getcwd(),1))
> 
> So if you run bzr in the directory where it's installed, I think this
> could remove the only reference to the bzrlib directory, and prevent
> bzrlib from loading.  Similarly, it could remove references to other
> paths needed for Bazaar to run.

Yes. Exactly. If you read all comments you'll see that I think this problem
can not be solved for all possible use cases. Checking that os.getcwd()
is not C:\Python25\Lib\site-packages or similar path on Linux -- is too much IMO.
Actually I don't think the bug #53478 it's the bzr bug. And your comment only confirm this.
This bug only affects Python 2.4, not Python 2.5.

I really prefer to do not "fix" it.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSEZQzYr338mxwCURAt9+AJ9hzdC5/EJ+z6FaT0cNByBK6SjyCwCglKkO
Iq2KqADPhlUtl47MULOoFM4=
=LDUl
-----END PGP SIGNATURE-----



More information about the bazaar mailing list