bpo-42923: Dump extension modules on fatal error (GH-24207)

The Py_FatalError() function and the faulthandler module now dump the
list of extension modules on a fatal error.

Add _Py_DumpExtensionModules() and _PyModule_IsExtension() internal
functions.
This commit is contained in:
Victor Stinner 2021-01-18 20:47:13 +01:00 committed by GitHub
parent f7b5bacd7a
commit 250035d134
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 96 additions and 0 deletions

View file

@ -35,6 +35,19 @@ PyTypeObject PyModuleDef_Type = {
};
int
_PyModule_IsExtension(PyObject *obj)
{
if (!PyModule_Check(obj)) {
return 0;
}
PyModuleObject *module = (PyModuleObject*)obj;
struct PyModuleDef *def = module->md_def;
return (def != NULL && def->m_methods != NULL);
}
PyObject*
PyModuleDef_Init(struct PyModuleDef* def)
{