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
|
@ -34,7 +34,6 @@
|
|||
#include "prepare_protocol.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "pycore_import.h" // _PyImport_GetModuleAttrString()
|
||||
#include "pycore_modsupport.h" // _PyArg_NoKeywords()
|
||||
#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
|
||||
#include "pycore_pylifecycle.h" // _Py_IsInterpreterFinalizing()
|
||||
|
@ -2000,7 +1999,7 @@ pysqlite_connection_iterdump_impl(pysqlite_Connection *self,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
PyObject *iterdump = _PyImport_GetModuleAttrString(MODULE_NAME ".dump", "_iterdump");
|
||||
PyObject *iterdump = PyImport_ImportModuleAttrString(MODULE_NAME ".dump", "_iterdump");
|
||||
if (!iterdump) {
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(self->OperationalError,
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#include "row.h"
|
||||
#include "blob.h"
|
||||
|
||||
#include "pycore_import.h" // _PyImport_GetModuleAttrString()
|
||||
|
||||
#if SQLITE_VERSION_NUMBER < 3015002
|
||||
#error "SQLite 3.15.2 or higher required"
|
||||
#endif
|
||||
|
@ -234,7 +232,7 @@ static int
|
|||
load_functools_lru_cache(PyObject *module)
|
||||
{
|
||||
pysqlite_state *state = pysqlite_get_state(module);
|
||||
state->lru_cache = _PyImport_GetModuleAttrString("functools", "lru_cache");
|
||||
state->lru_cache = PyImport_ImportModuleAttrString("functools", "lru_cache");
|
||||
if (state->lru_cache == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue