mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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
|
@ -1839,7 +1839,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
|
|||
assert(object && format && timetuple);
|
||||
assert(PyUnicode_Check(format));
|
||||
|
||||
PyObject *strftime = _PyImport_GetModuleAttrString("time", "strftime");
|
||||
PyObject *strftime = PyImport_ImportModuleAttrString("time", "strftime");
|
||||
if (strftime == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2022,7 +2022,7 @@ static PyObject *
|
|||
time_time(void)
|
||||
{
|
||||
PyObject *result = NULL;
|
||||
PyObject *time = _PyImport_GetModuleAttrString("time", "time");
|
||||
PyObject *time = PyImport_ImportModuleAttrString("time", "time");
|
||||
|
||||
if (time != NULL) {
|
||||
result = PyObject_CallNoArgs(time);
|
||||
|
@ -2040,7 +2040,7 @@ build_struct_time(int y, int m, int d, int hh, int mm, int ss, int dstflag)
|
|||
PyObject *struct_time;
|
||||
PyObject *result;
|
||||
|
||||
struct_time = _PyImport_GetModuleAttrString("time", "struct_time");
|
||||
struct_time = PyImport_ImportModuleAttrString("time", "struct_time");
|
||||
if (struct_time == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue