summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2017-09-04 23:54:09 (GMT)
committerGitHub <noreply@github.com>2017-09-04 23:54:09 (GMT)
commit86b7afdfeee77993fe896a2aa13b3f4f95973f16 (patch)
treea37fbb7233319c671e4787bff683629148cab971 /Objects
parentf5ea83f4864232fecc042ff0d1c2401807b19280 (diff)
downloadcpython-86b7afdfeee77993fe896a2aa13b3f4f95973f16.zip
cpython-86b7afdfeee77993fe896a2aa13b3f4f95973f16.tar.gz
cpython-86b7afdfeee77993fe896a2aa13b3f4f95973f16.tar.bz2
bpo-28411: Remove "modules" field from Py_InterpreterState. (#1638)
sys.modules is the one true source.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/moduleobject.c12
-rw-r--r--Objects/typeobject.c3
2 files changed, 10 insertions, 5 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 02a8cf0..89afe29 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -161,11 +161,17 @@ _add_methods_to_object(PyObject *module, PyObject *name, PyMethodDef *functions)
PyObject *
PyModule_Create2(struct PyModuleDef* module, int module_api_version)
{
+ if (!_PyImport_IsInitialized(PyThreadState_GET()->interp))
+ Py_FatalError("Python import machinery not initialized");
+ return _PyModule_CreateInitialized(module, module_api_version);
+}
+
+PyObject *
+_PyModule_CreateInitialized(struct PyModuleDef* module, int module_api_version)
+{
const char* name;
PyModuleObject *m;
- PyInterpreterState *interp = PyThreadState_Get()->interp;
- if (interp->modules == NULL)
- Py_FatalError("Python import machinery not initialized");
+
if (!PyModuleDef_Init(module))
return NULL;
name = module->m_name;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index d1a12a7..1d963aa 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3901,7 +3901,6 @@ import_copyreg(void)
{
PyObject *copyreg_str;
PyObject *copyreg_module;
- PyInterpreterState *interp = PyThreadState_GET()->interp;
_Py_IDENTIFIER(copyreg);
copyreg_str = _PyUnicode_FromId(&PyId_copyreg);
@@ -3913,7 +3912,7 @@ import_copyreg(void)
by storing a reference to the cached module in a static variable, but
this broke when multiple embedded interpreters were in use (see issue
#17408 and #19088). */
- copyreg_module = PyDict_GetItemWithError(interp->modules, copyreg_str);
+ copyreg_module = _PyImport_GetModuleWithError(copyreg_str);
if (copyreg_module != NULL) {
Py_INCREF(copyreg_module);
return copyreg_module;