gh-128911: Add PyImport_ImportModuleAttr() function (#128912)

Add PyImport_ImportModuleAttr() and
PyImport_ImportModuleAttrString() functions.

* Add unit tests.
* Replace _PyImport_GetModuleAttr()
  with PyImport_ImportModuleAttr().
* Replace _PyImport_GetModuleAttrString()
  with PyImport_ImportModuleAttrString().
* Remove "pycore_import.h" includes, no longer needed.
This commit is contained in:
Victor Stinner 2025-01-30 12:17:29 +01:00 committed by GitHub
parent f927204f64
commit 3bebe46d34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 194 additions and 56 deletions

View file

@ -1346,7 +1346,7 @@ PyInit_faulthandler(void)
static int
faulthandler_init_enable(void)
{
PyObject *enable = _PyImport_GetModuleAttrString("faulthandler", "enable");
PyObject *enable = PyImport_ImportModuleAttrString("faulthandler", "enable");
if (enable == NULL) {
return -1;
}