diff Python/pythonrun.c @ 17286:992460c668c1 2.0

- #119862 - getargs.c - patched memory leak - #128475 - pythonrun.c - In Py_Finalize, don't reset initialized flag until after the exit funcs have run
author Moshe Zadka <moshez@math.huji.ac.il>
date Sat, 31 Mar 2001 13:18:35 +0000
parents 37397bd1f8a8
children
line wrap: on
line diff
--- a/Python/pythonrun.c	Sat Mar 31 11:14:43 2001 +0000
+++ b/Python/pythonrun.c	Sat Mar 31 13:18:35 2001 +0000
@@ -183,10 +183,19 @@
 
 	if (!initialized)
 		return;
+
+	/* The interpreter is still entirely intact at this point, and the
+	 * exit funcs may be relying on that.  In particular, if some thread
+	 * or exit func is still waiting to do an import, the import machinery
+	 * expects Py_IsInitialized() to return true.  So don't say the
+	 * interpreter is uninitialized until after the exit funcs have run.
+	 * Note that Threading.py uses an exit func to do a join on all the
+	 * threads created thru it, so this also protects pending imports in
+	 * the threads created via Threading.
+	 */
+	call_sys_exitfunc();
 	initialized = 0;
 
-	call_sys_exitfunc();
-
 	/* Get current thread state and interpreter pointer */
 	tstate = PyThreadState_Get();
 	interp = tstate->interp;