diff Python/pythonrun.c @ 28613:b1671550c7e1 legacy-trunk

Move the call to _Py_PrintReferences() a bit further down. This prevents it from showing stuff (like codec state) that is cleared when the interpreter state is cleared.
author Guido van Rossum <guido@python.org>
date Tue, 15 Apr 2003 14:10:09 +0000
parents be2ecafb15ad
children 4f0b7acffc7d
line wrap: on
line diff
--- a/Python/pythonrun.c	Tue Apr 15 12:43:26 2003 +0000
+++ b/Python/pythonrun.c	Tue Apr 15 14:10:09 2003 +0000
@@ -270,12 +270,6 @@
 	fprintf(stderr, "[%ld refs]\n", _Py_RefTotal);
 #endif
 
-#ifdef Py_TRACE_REFS
-	if (Py_GETENV("PYTHONDUMPREFS")) {
-		_Py_PrintReferences(stderr);
-	}
-#endif /* Py_TRACE_REFS */
-
 	/* 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
@@ -283,11 +277,22 @@
 	*/
 	_PyExc_Fini();
 
+	/* Clear interpreter state */
+	PyInterpreterState_Clear(interp);
+
+#ifdef Py_TRACE_REFS
+	/* Dump references -- this may implicitly need the thread state,
+	   so this is the last possible place where we can do this. */
+	if (Py_GETENV("PYTHONDUMPREFS")) {
+		_Py_PrintReferences(stderr);
+	}
+#endif /* Py_TRACE_REFS */
+
 	/* Delete current thread */
-	PyInterpreterState_Clear(interp);
 	PyThreadState_Swap(NULL);
 	PyInterpreterState_Delete(interp);
 
+	/* Sundry finalizers */
 	PyMethod_Fini();
 	PyFrame_Fini();
 	PyCFunction_Fini();