mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
bpo-40956: Convert sqlite3.connect and sqlite3.Connection.__init__ to AC (GH-24421)
This commit is contained in:
parent
09eb817115
commit
185ecdc146
6 changed files with 298 additions and 71 deletions
|
@ -79,40 +79,34 @@ new_statement_cache(pysqlite_Connection *self, int maxsize)
|
|||
return res;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_sqlite3.Connection.__init__ as pysqlite_connection_init
|
||||
|
||||
database as database_obj: object(converter='PyUnicode_FSConverter')
|
||||
timeout: double = 5.0
|
||||
detect_types: int = 0
|
||||
isolation_level: object = NULL
|
||||
check_same_thread: bool(accept={int}) = True
|
||||
factory: object(c_default='(PyObject*)clinic_state()->ConnectionType') = ConnectionType
|
||||
cached_statements: int = 128
|
||||
uri: bool = False
|
||||
[clinic start generated code]*/
|
||||
|
||||
static int
|
||||
pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,
|
||||
PyObject *kwargs)
|
||||
pysqlite_connection_init_impl(pysqlite_Connection *self,
|
||||
PyObject *database_obj, double timeout,
|
||||
int detect_types, PyObject *isolation_level,
|
||||
int check_same_thread, PyObject *factory,
|
||||
int cached_statements, int uri)
|
||||
/*[clinic end generated code: output=dc19df1c0e2b7b77 input=aa1f21bf12fe907a]*/
|
||||
{
|
||||
static char *kwlist[] = {
|
||||
"database", "timeout", "detect_types", "isolation_level",
|
||||
"check_same_thread", "factory", "cached_statements", "uri",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char* database;
|
||||
PyObject* database_obj;
|
||||
int detect_types = 0;
|
||||
PyObject* isolation_level = NULL;
|
||||
PyObject* factory = NULL;
|
||||
int check_same_thread = 1;
|
||||
int cached_statements = 128;
|
||||
int uri = 0;
|
||||
double timeout = 5.0;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|diOiOip", kwlist,
|
||||
PyUnicode_FSConverter, &database_obj, &timeout, &detect_types,
|
||||
&isolation_level, &check_same_thread,
|
||||
&factory, &cached_statements, &uri))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PySys_Audit("sqlite3.connect", "O", database_obj) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
database = PyBytes_AsString(database_obj);
|
||||
const char *database = PyBytes_AsString(database_obj);
|
||||
|
||||
self->initialized = 1;
|
||||
|
||||
|
@ -134,7 +128,7 @@ pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,
|
|||
(uri ? SQLITE_OPEN_URI : 0), NULL);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
Py_DECREF(database_obj);
|
||||
Py_DECREF(database_obj); // needed bco. the AC FSConverter
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
_pysqlite_seterror(self->db);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue