diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2017-09-04 17:54:09 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-04 17:54:09 -0600 |
commit | 86b7afdfeee77993fe896a2aa13b3f4f95973f16 (patch) | |
tree | a37fbb7233319c671e4787bff683629148cab971 /Modules/_pickle.c | |
parent | f5ea83f4864232fecc042ff0d1c2401807b19280 (diff) | |
download | cpython-git-86b7afdfeee77993fe896a2aa13b3f4f95973f16.tar.gz |
bpo-28411: Remove "modules" field from Py_InterpreterState. (#1638)
sys.modules is the one true source.
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r-- | Modules/_pickle.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index a6f3abeba0..2a3e73988d 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -6418,9 +6418,7 @@ _pickle_Unpickler_find_class_impl(UnpicklerObject *self, /*[clinic end generated code: output=becc08d7f9ed41e3 input=e2e6a865de093ef4]*/ { PyObject *global; - PyObject *modules_dict; PyObject *module; - _Py_IDENTIFIER(modules); /* Try to map the old names used in Python 2.x to the new ones used in Python 3.x. We do this only with old pickle protocols and when the @@ -6477,13 +6475,7 @@ _pickle_Unpickler_find_class_impl(UnpicklerObject *self, } } - modules_dict = _PySys_GetObjectId(&PyId_modules); - if (modules_dict == NULL) { - PyErr_SetString(PyExc_RuntimeError, "unable to get sys.modules"); - return NULL; - } - - module = PyDict_GetItemWithError(modules_dict, module_name); + module = PyImport_GetModule(module_name); if (module == NULL) { if (PyErr_Occurred()) return NULL; @@ -6491,11 +6483,11 @@ _pickle_Unpickler_find_class_impl(UnpicklerObject *self, if (module == NULL) return NULL; global = getattribute(module, global_name, self->proto >= 4); - Py_DECREF(module); } else { global = getattribute(module, global_name, self->proto >= 4); } + Py_DECREF(module); return global; } |