[Bug 53478] Re: python imports from the current working directory on win32

Alexander Belchenko bialix at ukr.net
Sat Nov 24 08:21:37 GMT 2007


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

Robert Collins пишет:
> On Fri, 2007-11-23 at 21:05 +0000, Alexander Belchenko wrote:
>> I don't think it's a bzr bug. I'd prefer to change it to wontfix.
> 
> Python itself can cause it, it's true. That is, if '' is on sys.path,
> bzr will load from the cwd.
> 
> While I don't think bzr causes this, we should make sure we work
> correctly when it happens.

In my understanding it's completely impossible to achieve this goal
because of broken design of our underlying platform: CPython interpreter.
I.e. we can't guarantee for all possible use cases that bzrlib will
work out gracefully any malicious or random attempt to import bad module
instead of standard one. It's just problem of python programers,
who write their own python programs an use module names that identical
to standard library ones.

Because now bzrlib uses full python-path to their own internals, the only
problem here is standard library. And we can't workaround this. At least
I don;t see the way.

We can provide guard code only in bzr script, IMO.
Because I have use case that annoys me for last 2 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. This problem is fixable in my understanding:
replace '' in sys.path with full path to running bzr script itself.
And I'm about to provide patch to fix it in bzr script (only).

But at the bzrlib level we can't and shouldn't manipulate with sys.path.
It's my strong IMO.

Newer version of Python interpreter also try to address this problem
via absolute import mechanism. We (bzrlib) can't do it instead of Python.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHR98RzYr338mxwCURApwMAKCMCrA3KVbfrGn0k+0Fp2UezeWN4ACeKuoV
7uGKY3JuFOz1m4/9NHWp0JY=
=OtXe
-----END PGP SIGNATURE-----



More information about the bazaar mailing list