[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-bugs-list
Subject:    [ python-Bugs-1074015 ] current directory in sys.path handles
From:       noreply () sourceforge ! net (SourceForge ! net)
Date:       2004-11-27 0:07:49
Message-ID: E1CXpBp-0003wp-Qp () sc8-sf-web1 ! sourceforge ! net
[Download RAW message or body]

Bugs item #1074015, was opened at 2004-11-26 17:07
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1074015&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Eric M. Hopper (omnifarious)
Assigned to: Nobody/Anonymous (nobody)
Summary: current directory in sys.path handles symlinks badly

Initial Comment:
Here is a script to create the bug:
------------
rm -rf joe barney lib
mkdir joe
mkdir barney
echo "import pprint, sys" >joe/joe.py
echo "pprint.pprint(sys.path)" >>joe/joe.py
echo "import barney" >>joe/joe.py
touch barney/barney.py
mkdir lib
cd lib
ln -s ../joe/joe.py ../barney/barney.py .
python2.3 joe.py
------------

The output for this is:

['/home/hopper/tmp/py-bug/joe',
 '/usr/lib/python23.zip',
 '/usr/lib/python2.3',
 '/usr/lib/python2.3/plat-linux2',
 '/usr/lib/python2.3/lib-tk',
 '/usr/lib/python2.3/lib-dynload',
 '/usr/lib/python2.3/site-packages',
 '/usr/lib/python2.3/site-packages/gtk-2.0']
Traceback (most recent call last):
  File "joe.py", line 3, in ?
    import barney
ImportError: No module named barney

The script should be able to run successfully.

What's going wrong is this...
When python loads up 'joe.py' at startup, it looks at
it and notices it's a symlink.  So it adds the
directory for the file the symlink ultimately resolves
to to the path.  This is almost a wise thing to do, but
not quite.

What should happen is that it should look up the
directory the file is in, and if _that's_ a symlink,
put the directory it ultimately resolves to on the path.

We have a deployment system where I work that builds
deployment directories by symlinking things into them.
 This sets it up so sys.path ofen has surprising and
confusing values, depending on what script you run with
the interpreter.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1074015&group_id=5470

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic