summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorMoshe Zadka <moshez@math.huji.ac.il>2001-03-31 13:18:35 (GMT)
committerMoshe Zadka <moshez@math.huji.ac.il>2001-03-31 13:18:35 (GMT)
commit175a46d18f7261cdc6e7d077b37d50bed86cba12 (patch)
treeb2be1bbb1f47f7bdf9f9e158a9532bda28255a1f /Python/pythonrun.c
parentd0851885c6af2e4d5381950a9d996d8d372b7532 (diff)
downloadcpython-175a46d18f7261cdc6e7d077b37d50bed86cba12.zip
cpython-175a46d18f7261cdc6e7d077b37d50bed86cba12.tar.gz
cpython-175a46d18f7261cdc6e7d077b37d50bed86cba12.tar.bz2
- #119862 - getargs.c - patched memory leak
- #128475 - pythonrun.c - In Py_Finalize, don't reset initialized flag until after the exit funcs have run
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index e29e719..e0af0da 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -183,9 +183,18 @@ Py_Finalize(void)
if (!initialized)
return;
- initialized = 0;
+ /* 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;
/* Get current thread state and interpreter pointer */
tstate = PyThreadState_Get();