Comment 19 for bug 72227

Revision history for this message
Forest Bond (forest-bond) wrote : Re: [Bug 72227] Re: should avoid loading modules from working directory

Hi,

 affects bzr
 status invalid

 affects ubuntu/bzr
 status invalid

On Thu, Jul 16, 2009 at 02:24:24PM -0000, John A Meinel wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> ...
>
> > 09:54 forest@W038$ python /tmp/foo/test.py
> > ['/tmp/foo', '/home/forest/usr/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg', '/home/forest/usr/lib/python2.5/site-packages/Satchmo-0.9_pre-py2.5.egg', '/home/forest/lib/python', '/home/forest/usr/lib/python2.6/site-packages', '/home/forest/usr/lib/python2.5/site-packages', '/home/forest/usr/lib/python2.4/site-packages', '/home/forest/usr/lib/python2.3/site-packages',
> > '/tmp/bar', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/var/lib/python-support/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/var/lib/python-support/python2.6/gtk-2.0', '/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode', '/usr/local/lib/python2.6/dist-packages', '/home/forest/usr/lib/python2.4/site-packages', '/home/forest/usr/lib/python2.3/site-packages']
>
> > [/tmp/bar]
>
> ^- So indeed, /tmp/bar is in your path.

Correct.

> What I've seen in the past, is that if you insert debug statements into
> *site.py* it gets a '' in sys.path, and then it calls a function to turn
> all paths in 'sys.path' into absolute paths (and thus '' => $PWD).

Indeed, this is what is happening. Here's why:

My .bashrc does export PYTHONPATH="foo:$PYTHONPATH". Given that PYTHONPATH is
empty before it executes, I end up with PYTHONPATH "foo:". The trailing :
results in '' being in sys.path. Python then translates this to $PWD.

So this is my fault, more-or-less. My apologies. I'll go make my .bashrc more
complicated.

-Forest
--
Forest Bond
http://www.alittletooquiet.net
http://www.pytagsfs.org