Import site failed, and freezing.

Gustavo Niemeyer niemeyer at conectiva.com
Mon Jan 28 07:17:02 EST 2002


> After changing to Python 2.2 I came across a peculiar error.
> I have modules in my system which I freeze separately on a 
> Linux Redhat 7.2 box. However, after switching to 2.2, one of the 
> modules reports:
> 
> "import site failed" 
[...]

There's a little bug in the site module. Have a look at line 95. There
sys.path[-1] is being accessed without being tested first. If you follow
Py_FrozenMain you'll notice that freezed modules may have an empty sys.path,
and it breaks.

You may fix site.py and add a test to verify if sys.path is not an empty
list before accessing its last element (-1), or set sys.path in the
command line using PYTHONPATH environment variable. You may also change
Py_FrozenMain and set sys.path to something like Py_GetPath() there.

Best regards!

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20020128/aa87fb1b/attachment.sig>


More information about the Python-list mailing list