]> granicus.if.org Git - python/commitdiff
Backout 62658d9d8926 (issue #10241): it causes a crash at shutdown when deallocating...
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 2 Aug 2013 18:39:46 +0000 (20:39 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 2 Aug 2013 18:39:46 +0000 (20:39 +0200)
Include/pystate.h
Misc/NEWS
Python/import.c
Python/pystate.c

index e41fe4c0d5f085fdd2dfc7b0b73704ce6ee1d187..cd1d7765be0c9dfb3c4febf2ee91c9ee1b220af1 100644 (file)
@@ -134,9 +134,6 @@ PyAPI_FUNC(int) PyState_AddModule(PyObject*, struct PyModuleDef*);
 PyAPI_FUNC(int) PyState_RemoveModule(struct PyModuleDef*);
 #endif
 PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*);
-#ifndef Py_LIMITED_API
-PyAPI_FUNC(void) _PyState_ClearModules(void);
-#endif
 
 PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
 PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
index bc6a810fb1e6f4555179a5184232ffa3605864a3..027f5a72d822456938d8710431ccdbb41e9b858d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,9 +12,6 @@ Core and Builtins
 
 - Issue #17899: Fix rare file descriptor leak in os.listdir().
 
-- Issue #10241: Clear extension module dict copies at interpreter shutdown.
-  Patch by Neil Schemenauer, minimally modified.
-
 - Issue #9035: ismount now recognises volumes mounted below a drive root
   on Windows. Original patch by Atsuo Ishimoto.
 
index ce09ebedd4915308b861ec69a4d39b783197ab01..09106555a3b87494cf9de2f8d403cbba8cddb279 100644 (file)
@@ -380,8 +380,6 @@ PyImport_Cleanup(void)
     builtins = interp->builtins;
     interp->builtins = PyDict_New();
     Py_DECREF(builtins);
-    /* Clear module dict copies stored in the interpreter state */
-    _PyState_ClearModules();
     /* Collect references */
     _PyGC_CollectNoFail();
     /* Dump GC stats before it's too late, since it uses the warnings
index 924b6a29090644218a876d0ace68ba074a776fdc..40606bf1ca71f7457801dbce434b82d8d9c65cfa 100644 (file)
@@ -320,31 +320,6 @@ PyState_RemoveModule(struct PyModuleDef* def)
     return PyList_SetItem(state->modules_by_index, index, Py_None);
 }
 
-/* used by import.c:PyImport_Cleanup */
-void
-_PyState_ClearModules(void)
-{
-    PyInterpreterState *state = PyThreadState_GET()->interp;
-    if (state->modules_by_index) {
-        Py_ssize_t i;
-        for (i = 0; i < PyList_GET_SIZE(state->modules_by_index); i++) {
-            PyObject *m = PyList_GET_ITEM(state->modules_by_index, i);
-            if (PyModule_Check(m)) {
-                /* cleanup the saved copy of module dicts */
-                PyModuleDef *md = PyModule_GetDef(m);
-                if (md)
-                    Py_CLEAR(md->m_base.m_copy);
-            }
-        }
-        /* Setting modules_by_index to NULL could be dangerous, so we
-           clear the list instead. */
-        if (PyList_SetSlice(state->modules_by_index,
-                            0, PyList_GET_SIZE(state->modules_by_index),
-                            NULL))
-            PyErr_WriteUnraisable(state->modules_by_index);
-    }
-}
-
 void
 PyThreadState_Clear(PyThreadState *tstate)
 {