summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/moduleobject.c12
-rw-r--r--Objects/object.c27
-rw-r--r--Objects/typeobject.c3
3 files changed, 17 insertions, 25 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 2be49fb..5fab06d 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -162,17 +162,11 @@ _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/object.c b/Objects/object.c
index ed8a62a..74893e3 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -29,23 +29,20 @@ _Py_GetRefTotal(void)
return total;
}
-PyObject *
-_PyDebug_XOptionShowRefCount(void)
-{
- PyObject *xoptions = PySys_GetXOptions();
- if (xoptions == NULL)
- return NULL;
-
- _Py_IDENTIFIER(showrefcount);
- return _PyDict_GetItemId(xoptions, &PyId_showrefcount);
-}
-
void
_PyDebug_PrintTotalRefs(void) {
- fprintf(stderr,
- "[%" PY_FORMAT_SIZE_T "d refs, "
- "%" PY_FORMAT_SIZE_T "d blocks]\n",
- _Py_GetRefTotal(), _Py_GetAllocatedBlocks());
+ PyObject *xoptions, *value;
+ _Py_IDENTIFIER(showrefcount);
+
+ xoptions = PySys_GetXOptions();
+ if (xoptions == NULL)
+ return;
+ value = _PyDict_GetItemId(xoptions, &PyId_showrefcount);
+ if (value == Py_True)
+ fprintf(stderr,
+ "[%" PY_FORMAT_SIZE_T "d refs, "
+ "%" PY_FORMAT_SIZE_T "d blocks]\n",
+ _Py_GetRefTotal(), _Py_GetAllocatedBlocks());
}
#endif /* Py_REF_DEBUG */
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index a06cab7..dc4d2ed 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3902,6 +3902,7 @@ 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 +3914,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 = _PyImport_GetModuleWithError(copyreg_str);
+ copyreg_module = PyDict_GetItemWithError(interp->modules, copyreg_str);
if (copyreg_module != NULL) {
Py_INCREF(copyreg_module);
return copyreg_module;