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
|
@ -775,7 +775,7 @@ _lsprof_Profiler_enable_impl(ProfilerObject *self, int subcalls,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
PyObject* monitoring = _PyImport_GetModuleAttrString("sys", "monitoring");
|
||||
PyObject* monitoring = PyImport_ImportModuleAttrString("sys", "monitoring");
|
||||
if (!monitoring) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -857,7 +857,7 @@ _lsprof_Profiler_disable_impl(ProfilerObject *self)
|
|||
}
|
||||
if (self->flags & POF_ENABLED) {
|
||||
PyObject* result = NULL;
|
||||
PyObject* monitoring = _PyImport_GetModuleAttrString("sys", "monitoring");
|
||||
PyObject* monitoring = PyImport_ImportModuleAttrString("sys", "monitoring");
|
||||
|
||||
if (!monitoring) {
|
||||
return NULL;
|
||||
|
@ -973,7 +973,7 @@ profiler_init_impl(ProfilerObject *self, PyObject *timer, double timeunit,
|
|||
Py_XSETREF(self->externalTimer, Py_XNewRef(timer));
|
||||
self->tool_id = PY_MONITORING_PROFILER_ID;
|
||||
|
||||
PyObject* monitoring = _PyImport_GetModuleAttrString("sys", "monitoring");
|
||||
PyObject* monitoring = PyImport_ImportModuleAttrString("sys", "monitoring");
|
||||
if (!monitoring) {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue