Index: Python/pythonrun.c =================================================================== --- Python/pythonrun.c (revision 59115) +++ Python/pythonrun.c (working copy) @@ -437,14 +437,15 @@ _Py_PrintReferences(stderr); #endif /* Py_TRACE_REFS */ + + /* Clear interpreter state */ + PyInterpreterState_Clear(interp); + /* Cleanup auto-thread-state */ #ifdef WITH_THREAD _PyGILState_Fini(); #endif /* WITH_THREAD */ - /* Clear interpreter state */ - PyInterpreterState_Clear(interp); - /* Now we decref the exception classes. After this point nothing can raise an exception. That's okay, because each Fini() method below has been checked to make sure no exceptions are ever