gh-128911: Use PyImport_ImportModuleAttr() function (#129657)

* Replace PyImport_ImportModule() + PyObject_GetAttr() with
  PyImport_ImportModuleAttr().
* Replace PyImport_ImportModule() + PyObject_GetAttrString() with
  PyImport_ImportModuleAttrString().
This commit is contained in:
Victor Stinner 2025-02-05 11:03:58 +01:00 committed by GitHub
parent fb5d1c9236
commit dc804ffb2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 32 additions and 84 deletions

View file

@ -1057,15 +1057,10 @@ test_pep3118_obsolete_write_locks(PyObject* self, PyObject *Py_UNUSED(ignored))
if (ret != -1 || match == 0)
goto error;
PyObject *mod_io = PyImport_ImportModule("_io");
if (mod_io == NULL) {
return NULL;
}
/* bytesiobuf_getbuffer() */
PyTypeObject *type = (PyTypeObject *)PyObject_GetAttrString(
mod_io, "_BytesIOBuffer");
Py_DECREF(mod_io);
PyTypeObject *type = (PyTypeObject *)PyImport_ImportModuleAttrString(
"_io",
"_BytesIOBuffer");
if (type == NULL) {
return NULL;
}