[ python-Bugs-794291 ] double symlinking corrupts sys.path[0]

SourceForge.net noreply at sourceforge.net
Sat Jan 15 20:50:56 CET 2005


Bugs item #794291, was opened at 2003-08-24 16:52
Message generated for change (Settings changed) made by facundobatista
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=794291&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Csaba Henk (dzsekijo)
Assigned to: Nobody/Anonymous (nobody)
Summary: double symlinking corrupts sys.path[0]

Initial Comment:
The bug can be demonstrated as follows

(In some Bourne-tpye Unix shell) type 

$ mkdir d1 d2 && 
echo 'import sys
print sys.path[0]' > d1/script.py &&
ln -s ../d1/script.py d2 && 
ln -s d2/script.py .

Now see what the  three invocations of  script.py give us:

$ python d1/script.py 
d1
$ python d2/script.py 
d2/../d1
$ python script.py 
d2

--  if script.py imported modules residing in d1, at
the third invocation the modules would not be found.

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

Comment By: Steven Taschuk (staschuk)
Date: 2003-08-28 02:39

Message:
Logged In: YES 
user_id=666873

I confirm this behaviour on Linux 2.4.17 (glibc 2.2.4) with Python 
2.2.2 and 2.2.3; but not with Python 2.3.

The relevant change seems to be revision 2.114 of 
Python/sysmodule.c, which implemented SF patch #664376 (q.v.). 
 The change appeared in 2.3a2.

Should this be backported to the 2.2 line?

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

Comment By: Csaba Henk (dzsekijo)
Date: 2003-08-27 12:29

Message:
Logged In: YES 
user_id=754125

I hope the startup message is exact enough:

Python 2.2.2 (#1, May 19 2003, 03:15:27) 
[GCC 3.1] on linux2


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

Comment By: Christos Georgiou (tzot)
Date: 2003-08-27 08:46

Message:
Logged In: YES 
user_id=539787

My mistake, I missed the Pyhton 2.2.2 part, sorry.

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

Comment By: Christos Georgiou (tzot)
Date: 2003-08-27 08:45

Message:
Logged In: YES 
user_id=539787

Which version of Python?  With a recent 2.4 (built on Aug 21, 
sources of Aug 20), on a 2.4.19 SMP kernel:

$ mkdir d1 d2
$ echo 'import sys
> print sys.path[0]' >d1/script.py
$ ln -s ../d1/script.py d2
$ ln -s d2/script.py .
$ python d1/script.py
/tmp/tzot/d1
$ python d2/script.py
/tmp/tzot/d1
$ python script.py
/tmp/tzot/d1

Please specify OS too.

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

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


More information about the Python-bugs-list mailing list