mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
#4236: avoid possible Fatal Error when import is called from __del__
Patch by Simon Cross, crasher test code by Martin von Löwis.
This commit is contained in:
parent
95333e3aa9
commit
ce4b170c5a
3 changed files with 22 additions and 2 deletions
|
@ -63,8 +63,9 @@ PyModule_Create2(struct PyModuleDef* module, int module_api_version)
|
|||
PyMethodDef *ml;
|
||||
const char* name;
|
||||
PyModuleObject *m;
|
||||
if (!Py_IsInitialized())
|
||||
Py_FatalError("Interpreter not initialized (version mismatch?)");
|
||||
PyInterpreterState *interp = PyThreadState_Get()->interp;
|
||||
if (interp->modules == NULL)
|
||||
Py_FatalError("Python import machinery not initialized");
|
||||
if (PyType_Ready(&moduledef_type) < 0)
|
||||
return NULL;
|
||||
if (module->m_base.m_index == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue