summaryrefslogtreecommitdiffstats
path: root/Objects/moduleobject.c
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-12-14 23:06:25 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-12-14 23:06:25 (GMT)
commitce4b170c5a6ab03af66331871f827fb021cebe18 (patch)
tree520ad32eac01352bf8249cb8b4338218e41a33b1 /Objects/moduleobject.c
parent95333e3aa989c727b7a13ad32c1d169f70bd57ef (diff)
downloadcpython-ce4b170c5a6ab03af66331871f827fb021cebe18.zip
cpython-ce4b170c5a6ab03af66331871f827fb021cebe18.tar.gz
cpython-ce4b170c5a6ab03af66331871f827fb021cebe18.tar.bz2
#4236: avoid possible Fatal Error when import is called from __del__
Patch by Simon Cross, crasher test code by Martin von Löwis.
Diffstat (limited to 'Objects/moduleobject.c')
-rw-r--r--Objects/moduleobject.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 2c095a0..f31b5da 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -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) {