-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
PyType_GetModuleByDef
can return NULL
:
Lines 4640 to 4645 in fd49e22
PyErr_Format( | |
PyExc_TypeError, | |
"PyType_GetModuleByDef: No superclass of '%s' has the given module", | |
type->tp_name); | |
return NULL; | |
} |
I think that right now this is a hypothetical issue, because in practice NULL
will never be returned for these samples. But, all other similar places do check for NULL
. I guess that adding a check won't hurt. And in the future, if something changes - we would be safe.
Samples:
cpython/Modules/_threadmodule.c
Lines 903 to 904 in fd49e22
PyObject *module = PyType_GetModuleByDef(type, &thread_module); | |
thread_module_state *state = get_thread_state(module); |
cpython/Modules/_threadmodule.c
Lines 1044 to 1045 in fd49e22
PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &thread_module); | |
thread_module_state *state = get_thread_state(module); |
cpython/Modules/_threadmodule.c
Lines 1096 to 1097 in fd49e22
PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &thread_module); | |
thread_module_state *state = get_thread_state(module); |
Linked PRs
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error