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: Py_NewInterpreter() doesn't work
Type: Stage:
Components: None Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: geertj, joshhoyt, loewis
Priority: normal Keywords:

Created on 2003-01-15 20:17 by geertj, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (5)
msg14087 - (view) Author: Geert Jansen (geertj) * Date: 2003-01-15 20:17
Hello,

mod_python doesn't seem to work with Python 2.3a1. 
After some debugging, it seems the culprit is 
Py_NewInterpreter(). The following C program works with 
Python 2.2 but gives an error with Python 2.3:

#include <Python.h>

int main()
{
    PyThreadState *tstate; 
    Py_Initialize();
    tstate = Py_NewInterpreter();
    return 0;
}

The relevant part of this program's output:

geertj@cristina:~$ PYTHONVERBOSE=1 ./a.out 
# installing zipimport hook
import zipimport # builtin
[...]
import __builtin__ # previously loaded (__builtin__)
import sys # previously loaded (sys)
'import site' failed; traceback:
ImportError: No module named site

It seems that Python is unable to find the module "site".

Greetings,
Geert Jansen
msg14088 - (view) Author: Geert Jansen (geertj) * Date: 2003-01-15 20:19
Logged In: YES 
user_id=537938

I forgot to mention that the Python version used is 2.3a1.

Geert Jansen
msg14089 - (view) Author: Josh Hoyt (joshhoyt) Date: 2003-01-20 22:58
Logged In: YES 
user_id=693077

The problem appears to be that meta_path is not being
initialized in the new interpreter. Adding
_PyImportHooks_Init to Py_NewInterpreter seems to fix the
problem, initializing the new import hooks before trying to
import modules into the new interpreter.
msg14090 - (view) Author: Josh Hoyt (joshhoyt) Date: 2003-01-20 23:28
Logged In: YES 
user_id=693077

Patch 671459 seems to fix the problem.
msg14091 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-01-22 09:33
Logged In: YES 
user_id=21627

This was indeed fixed with that patch.
History
Date User Action Args
2022-04-10 16:06:08adminsetgithub: 37776
2003-01-15 20:17:50geertjcreate