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

SourceForge.net noreply@sourceforge.net
Sun, 08 Jun 2003 15:54:21 -0700


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: 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