[Python-bugs-list] [ python-Bugs-773476 ] import site fails in certain embedding situations

SourceForge.net noreply@sourceforge.net
Fri, 18 Jul 2003 06:30:42 -0700


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

>Category: Windows
Group: Python 2.3
Status: Open
Resolution: Accepted
Priority: 8
Submitted By: Mark Hammond (mhammond)
Assigned to: Mark Hammond (mhammond)
Summary: import site fails in certain embedding situations

Initial Comment:
In certain situations (python23.dll and python23.zip in
the same dir, no PYTHON related env vars set, no Python
registry values), Python will fail to import site.

Exception is:
import site # loaded from Zip
C:\build\mozilla\dist\bin\python23.zip\site.pyo
'import site' failed; traceback:
Traceback (most recent call last):
  File ".\site.py", line 191, in ?
NameError: name 'sitedir' is not defined

This exception is the result of there being no
"prefixes", so sitedir is never bound to a value. 
This, the del of sitedir fails.

Suggested patch is attached (just setting sitedir to
None before the loop)



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

Comment By: Mark Hammond (mhammond)
Date: 2003-07-18 23:29

Message:
Logged In: YES 
user_id=14198

The exception is "sitedir" - but I do concede a better patch
would involve sitedirs=[]; sitedir=None and zapping both. 
However, as site is executed as a standard module, the
cleanup of the namespace seems a little anal - especially
now we have __all__ - so maybe deleting the dels would be
better still <wink>

But given we are so close to release, and that the 'noun' in
the exception is singular, I still prefer None (but I would
be happy to settle for sitedir="winK" #wink)

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-07-18 18:06

Message:
Logged In: YES 
user_id=80475

"sitedir = []" would be a better choice.

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

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