Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 49003:812ea105b1b0
Fix a memory leak in reloading extension modules #3667
Reviewer: Barry Warsaw
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Thu, 04 Sep 2008 02:28:15 +0000 |
| parents | 3b9608118f8d |
| children | 3fa066d2a397 |
line wrap: on
line diff
--- a/Python/import.c Thu Sep 04 02:22:52 2008 +0000 +++ b/Python/import.c Thu Sep 04 02:28:15 2008 +0000 @@ -612,7 +612,6 @@ mod = PyImport_AddModule(name); if (mod == NULL) return NULL; - Py_INCREF(mod); mdict = PyModule_GetDict(mod); if (mdict == NULL) return NULL; @@ -626,6 +625,7 @@ if (mod == NULL) return NULL; PyDict_SetItemString(PyImport_GetModuleDict(), name, mod); + Py_DECREF(mod); } if (_PyState_AddModule(mod, def) < 0) { PyDict_DelItemString(PyImport_GetModuleDict(), name);
