[ python-Bugs-713601 ] site.py breaks if prefix is empty

SourceForge.net noreply at sourceforge.net
Sat Aug 7 21:58:43 CEST 2004


Bugs item #713601, was opened at 2003-04-01 15:40
Message generated for change (Comment added) made by bcannon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=713601&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Lalo Martins (lalo)
Assigned to: Nobody/Anonymous (nobody)
Summary: site.py breaks if prefix is empty

Initial Comment:
verified in 2.3a1 and 2.2.2:

prefixes = [sys.prefix]
if sys.exec_prefix != sys.prefix:
    prefixes.append(sys.exec_prefix)
for prefix in prefixes:
    if prefix:
        # do stuff - in particular, define the
"sitedir" variable
        # and add site-packages to the path
del prefix, sitedir

if sys.prefix == sys.exec_prefix and both are empty
(which is the case if you compile with --prefix=/ as
for the
Gnu OS for example), this will have two unfortunate
results:

1. site-packages will not be added to the path.

2. site.py will abort with a NameError (it tries to del
sitedir
which isn't defined)

The fix seems to be as simple as removing the "if prefix"
line.  From mailing list archives, it seems to have been
added to cope with unusual loading environments related
to windows and COM - in this case, there is probably a
safer way to check for this condition.  If the prefix is
empty, this just means it's the root, and no further
assumptions should be made.

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

>Comment By: Brett Cannon (bcannon)
Date: 2004-08-07 12:58

Message:
Logged In: YES 
user_id=357491

The NameError problem has been fixed.

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

Comment By: Daniel Goertzen (goertzen)
Date: 2004-04-08 12:09

Message:
Logged In: YES 
user_id=843814

See this patch:
931938	prefix and exec_prefix as root dir bug

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

Comment By: Daniel Goertzen (goertzen)
Date: 2004-04-08 09:01

Message:
Logged In: YES 
user_id=843814

Just ran into the same problem when I configure with --prefix=/

The problem is in getpath.c.  Before trying to find your
lib/python dir based on what you submitted in configure, it
performs a search based on the python execution path
(probably /bin).  It keeps chopping the path down with the
reduce() function and then adds "/lib/python" and sees if a
landmark file is there.  The problem is that reduce() will
freely chop away the last / leaving your prefix as a null
string.

I'm going to try tweaking reduce() so it doesn't hack off
the last / if its the last one.

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

Comment By: Brett Cannon (bcannon)
Date: 2003-06-08 15:54

Message:
Logged In: YES 
user_id=357491

Why is sys.prefix == '' if it is set to '/' as the command-line 
argument?  Checking Modules/getpath.c there appears a few 
places where things could go awry if an enviroment variable is 
set that causes the code to think it has already found the 
location before it reaches what the Makefile set PREFIX and 
EXEC_PREFIX to.  The steps used are in the initial comment of 
the file.  Any of those a possible reason for your problem?

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

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


More information about the Python-bugs-list mailing list