mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
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:
parent
f927204f64
commit
3bebe46d34
40 changed files with 194 additions and 56 deletions
|
@ -16,7 +16,6 @@
|
|||
#endif
|
||||
|
||||
#include "Python.h"
|
||||
#include "pycore_import.h" // _PyImport_GetModuleAttrString()
|
||||
#include "pycore_pyhash.h" // _Py_HashSecret
|
||||
|
||||
#include <stddef.h> // offsetof()
|
||||
|
@ -4393,7 +4392,7 @@ module_exec(PyObject *m)
|
|||
CREATE_TYPE(m, st->Element_Type, &element_spec);
|
||||
CREATE_TYPE(m, st->XMLParser_Type, &xmlparser_spec);
|
||||
|
||||
st->deepcopy_obj = _PyImport_GetModuleAttrString("copy", "deepcopy");
|
||||
st->deepcopy_obj = PyImport_ImportModuleAttrString("copy", "deepcopy");
|
||||
if (st->deepcopy_obj == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
@ -4403,7 +4402,7 @@ module_exec(PyObject *m)
|
|||
goto error;
|
||||
|
||||
/* link against pyexpat */
|
||||
if (!(st->expat_capsule = _PyImport_GetModuleAttrString("pyexpat", "expat_CAPI")))
|
||||
if (!(st->expat_capsule = PyImport_ImportModuleAttrString("pyexpat", "expat_CAPI")))
|
||||
goto error;
|
||||
if (!(st->expat_capi = PyCapsule_GetPointer(st->expat_capsule, PyExpat_CAPSULE_NAME)))
|
||||
goto error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue