mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +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
|
@ -362,7 +362,7 @@ _Pickle_InitState(PickleState *st)
|
|||
}
|
||||
Py_CLEAR(compat_pickle);
|
||||
|
||||
st->codecs_encode = _PyImport_GetModuleAttrString("codecs", "encode");
|
||||
st->codecs_encode = PyImport_ImportModuleAttrString("codecs", "encode");
|
||||
if (st->codecs_encode == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ _Pickle_InitState(PickleState *st)
|
|||
goto error;
|
||||
}
|
||||
|
||||
st->partial = _PyImport_GetModuleAttrString("functools", "partial");
|
||||
st->partial = PyImport_ImportModuleAttrString("functools", "partial");
|
||||
if (!st->partial)
|
||||
goto error;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue