[MERGE][1.0] disable python imports from cwd (problem with python2.4 @ win32: bug #53478)
Alexander Belchenko
bialix at ukr.net
Sun Nov 25 08:46:32 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert Collins пишет:
> On Sat, 2007-11-24 at 17:42 +0200, Alexander Belchenko wrote:
>
>
>> 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.
>
> There's a piece of information I'm not quite clear on.
>
> Does python2.4 on windows put '' in sys.path when bzr is run, or does it
> put realpath(cwd()) in sys.path?
>
> If its the former, I think we can robustly fix it. If it's the latter, I
> completely agree with Alexander.
I did experiments, and it seems that python put '' in sys.path only when
invoked as interactive interpreter, and '' placed instead of dirname(sys.argv[0]):
C:\Temp\4>python24
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'C:\\WINDOWS\\system32\\python24.zip', 'C:\\Temp\\4', 'C:\\Python24\\DLLs',
'C:\\Python24\\lib', 'C:\\Python24\\lib\\plat-win', 'C:\\Python24\\lib\\lib-tk', 'C:\\Python24',
'C:\\Python24\\lib\\site-packages', 'C:\\Python24\\lib\\site-packages\\win32',
'C:\\Python24\\lib\\site-packages\\win32\\lib', 'C:\\Python24\\lib\\site-packages\\Pythonwin']
Running simple script:
test.py:
import sys
print sys.path
C:\Temp\4>python24 test.py
['C:\\Temp\\4', 'C:\\WINDOWS\\system32\\python24.zip', 'C:\\Temp\\4', 'C:\\Python24\\DLLs',
'C:\\Python24\\lib', 'C:\\Python24\\lib\\plat-win', 'C:\\Python24\\lib\\lib-tk', 'C:\\Python24',
'C:\\Python24\\lib\\site-packages', 'C:\\Python24\\lib\\site-packages\\win32',
'C:\\Python24\\lib\\site-packages\\win32\\lib', 'C:\\Python24\\lib\\site-packages\\Pythonwin']
Actually cwd is sys.path[2] in both examples. But I'm not sure that some additional software
like setuptools don't change this order.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHSTZozYr338mxwCURAsI4AKCUY+Nv0PXK1j7sgjSVRw8HOf7IVgCfVXwL
aCzzYdO/sZOq7svNariMZLw=
=6tme
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list