mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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.
This commit is contained in:
parent
e82c034496
commit
3f9eee6eb4
11 changed files with 216 additions and 113 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue