diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2017-09-15 16:35:20 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-15 16:35:20 -0600 |
commit | 3f9eee6eb4b25fe1926eaa5f00e02344b126f54d (patch) | |
tree | c749747e0b4ce492d05c34ad5578b81128be1156 /Python/sysmodule.c | |
parent | e82c034496512139e9ea3f68ceda86c04bc7baab (diff) | |
download | cpython-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 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index d463683df1..6d2cc96b5e 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -162,18 +162,16 @@ static PyObject * sys_displayhook(PyObject *self, PyObject *o) { PyObject *outf; - PyObject *modules = PyImport_GetModuleDict(); - if (modules == NULL) - return NULL; PyObject *builtins; static PyObject *newline = NULL; int err; - builtins = _PyDict_GetItemId(modules, &PyId_builtins); + builtins = _PyImport_GetModuleId(&PyId_builtins); if (builtins == NULL) { PyErr_SetString(PyExc_RuntimeError, "lost builtins module"); return NULL; } + Py_DECREF(builtins); /* Print value except if None */ /* After printing, also assign to '_' */ |