[New-bugs-announce] [issue42243] Don't access the module dictionary directly

Erlend Egeberg Aasland report at bugs.python.org
Mon Nov 2 03:20:25 EST 2020


New submission from Erlend Egeberg Aasland <erlend.aasland at innova.no>:

Quoting from https://docs.python.org/3.10/c-api/module.html:
"It is recommended extensions use other PyModule_* and PyObject_* functions rather than directly manipulate a module’s __dict__."

A number of modules still access the module dictionary directly:
zsh % grep -r PyModule_GetDict Modules
Modules/errnomodule.c:    PyObject *module_dict = PyModule_GetDict(module);
Modules/_sre.c:    d = PyModule_GetDict(m);
Modules/_cursesmodule.c:    d = PyModule_GetDict(m);
Modules/_threadmodule.c:    d = PyModule_GetDict(m);
Modules/signalmodule.c:    PyObject *d = PyModule_GetDict(m);
Modules/_xxsubinterpretersmodule.c:    PyObject *ns = PyModule_GetDict(main_mod);  // borrowed
Modules/_xxsubinterpretersmodule.c:    PyObject *ns = PyModule_GetDict(module);  // borrowed
Modules/socketmodule.c:    dict = PyModule_GetDict(m);
Modules/_ssl.c:    d = PyModule_GetDict(m);
Modules/_curses_panel.c:    PyObject *d = PyModule_GetDict(mod);
Modules/_sqlite/connection.c:    module_dict = PyModule_GetDict(module);
Modules/_winapi.c:    PyObject *d = PyModule_GetDict(m);
Modules/pyexpat.c:    d = PyModule_GetDict(m);

----------
components: Library (Lib)
messages: 380197
nosy: erlendaasland
priority: normal
severity: normal
status: open
title: Don't access the module dictionary directly
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42243>
_______________________________________


More information about the New-bugs-announce mailing list