summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2017-09-15 16:35:20 -0600
committerGitHub <noreply@github.com>2017-09-15 16:35:20 -0600
commit3f9eee6eb4b25fe1926eaa5f00e02344b126f54d (patch)
treec749747e0b4ce492d05c34ad5578b81128be1156 /Objects
parente82c034496512139e9ea3f68ceda86c04bc7baab (diff)
downloadcpython-git-3f9eee6eb4b25fe1926eaa5f00e02344b126f54d.tar.gz
bpo-28411: Support other mappings in PyInterpreterState.modules. (#3593)
The concrete PyDict_* API is used to interact with PyInterpreterState.modules in a number of places. This isn't compatible with all dict subclasses, nor with other Mapping implementations. This patch switches the concrete API usage to the corresponding abstract API calls. We also add a PyImport_GetModule() function (and some other helpers) to reduce a bunch of code duplication.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 9ebbb21ef8..662c493ff2 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3913,10 +3913,8 @@ 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). */
- PyObject *modules = PyImport_GetModuleDict();
- copyreg_module = PyDict_GetItemWithError(modules, copyreg_str);
+ copyreg_module = PyImport_GetModule(copyreg_str);
if (copyreg_module != NULL) {
- Py_INCREF(copyreg_module);
return copyreg_module;
}
if (PyErr_Occurred()) {