]> granicus.if.org Git - python/commitdiff
Issue #10363: Deallocate global locks in Py_Finalize().
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 30 Oct 2011 18:13:55 +0000 (19:13 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 30 Oct 2011 18:13:55 +0000 (19:13 +0100)
Misc/NEWS
Python/import.c
Python/pystate.c

index 527874dae66792572a7bf9f39a80f1959fafe520..16c808c44c190f3d7d133efcf8e95fc760296901 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.2.3?
 Core and Builtins
 -----------------
 
+- Issue #10363: Deallocate global locks in Py_Finalize().
+
 - Issue #13018: Fix reference leaks in error paths in dictobject.c.
   Patch by Suman Saha.
 
index 2adcb04674113b0de3b68fdb1402347fab7b26f9..1dbe544e73aa00992b8050ef8ff3892bde8d7641 100644 (file)
@@ -252,16 +252,6 @@ _PyImportHooks_Init(void)
     Py_DECREF(path_hooks);
 }
 
-void
-_PyImport_Fini(void)
-{
-    Py_XDECREF(extensions);
-    extensions = NULL;
-    PyMem_DEL(_PyImport_Filetab);
-    _PyImport_Filetab = NULL;
-}
-
-
 /* Locking primitives to prevent parallel imports of the same module
    in different threads to return with a partially loaded module.
    These calls are serialized by the global interpreter lock. */
@@ -374,6 +364,21 @@ imp_release_lock(PyObject *self, PyObject *noargs)
     return Py_None;
 }
 
+void
+_PyImport_Fini(void)
+{
+    Py_XDECREF(extensions);
+    extensions = NULL;
+    PyMem_DEL(_PyImport_Filetab);
+    _PyImport_Filetab = NULL;
+#ifdef WITH_THREAD
+    if (import_lock != NULL) {
+        PyThread_free_lock(import_lock);
+        import_lock = NULL;
+    }
+#endif
+}
+
 static void
 imp_modules_reloading_clear(void)
 {
index b347c41c54a5ebfe82d40c6991273a0445862908..40699af499496327ab481f249972e1803ab56523 100644 (file)
@@ -150,6 +150,12 @@ PyInterpreterState_Delete(PyInterpreterState *interp)
     *p = interp->next;
     HEAD_UNLOCK();
     free(interp);
+#ifdef WITH_THREAD
+    if (interp_head == NULL && head_mutex != NULL) {
+        PyThread_free_lock(head_mutex);
+        head_mutex = NULL;
+    }
+#endif
 }