This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: import site fails in certain embedding situations
Type: Stage:
Components: Windows Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: jhylton Nosy List: gvanrossum, jhylton, mhammond, rhettinger, tim.peters
Priority: release blocker Keywords:

Created on 2003-07-18 07:52 by mhammond, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
site.patch mhammond, 2003-07-18 07:52 Patch
Messages (6)
msg17113 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2003-07-18 07:52
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)

msg17114 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-07-18 08:06
Logged In: YES 
user_id=80475

"sitedir = []" would be a better choice.
msg17115 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2003-07-18 13:29
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)
msg17116 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-07-18 13:45
Logged In: YES 
user_id=80475

Then None it is.
msg17117 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-07-18 16:22
Logged In: YES 
user_id=6380

Looks good to me, OK to check in AFAIC.
msg17118 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-07-18 18:24
Logged In: YES 
user_id=31435

Closing, as Jeremy said he applied this for 2.3c1.
History
Date User Action Args
2022-04-10 16:10:02adminsetgithub: 38875
2003-07-18 07:52:20mhammondcreate