Index: Python/pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.218 diff -w -u -r2.218 pythonrun.c --- Python/pythonrun.c 20 Oct 2005 19:59:25 -0000 2.218 +++ Python/pythonrun.c 21 Oct 2005 05:50:17 -0000 @@ -326,7 +326,6 @@ * the threads created via Threading. */ call_sys_exitfunc(); - initialized = 0; /* Get current thread state and interpreter pointer */ tstate = PyThreadState_GET(); @@ -353,6 +352,12 @@ */ PyGC_Collect(); + /* we need to clear initialized after collecting GC because + * collection may trigger an import hiding in a __del__ + * or weakref and we will get a Fatal Error from Py_InitModule4 + */ + initialized = 0; + /* Destroy all modules */ PyImport_Cleanup();