Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use PyObject_CallFunction iso. PyObject_CallFunctionObjArgs in sqlite…
…3.connect
  • Loading branch information
Erlend E. Aasland committed Jun 5, 2021
commit 4977d783eea356e3d5c991d00feaa51e8603c474
35 changes: 6 additions & 29 deletions Modules/_sqlite/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ pysqlite_connect_impl(PyObject *module, PyObject *database, double timeout,
int cached_statements, int uri)
/*[clinic end generated code: output=450ac9078b4868bb input=938c5058ce37130a]*/
{
PyObject *result = NULL;

if (isolation_level == NULL) {
isolation_level = PyUnicode_FromString("");
if (isolation_level == NULL) {
Expand All @@ -102,34 +100,13 @@ pysqlite_connect_impl(PyObject *module, PyObject *database, double timeout,
else {
Py_INCREF(isolation_level);
}

PyObject *obj_timeout = PyFloat_FromDouble(timeout);
PyObject *obj_detect_types = PyLong_FromLong(detect_types);
PyObject *obj_check_same_thread = PyLong_FromLong(check_same_thread);
PyObject *obj_cached_statements = PyLong_FromLong(cached_statements);
PyObject *obj_uri = PyBool_FromLong(uri);
if (obj_timeout == NULL || obj_detect_types == NULL ||
obj_check_same_thread == NULL || obj_cached_statements == NULL ||
obj_uri == NULL)
{
goto error;
}

result = PyObject_CallFunctionObjArgs(factory, database, obj_timeout,
obj_detect_types, isolation_level,
obj_check_same_thread, factory,
obj_cached_statements, obj_uri,
NULL);

error:
PyObject *res = PyObject_CallFunction(factory, "OdiOiOii", database,
timeout, detect_types,
isolation_level, check_same_thread,
factory, cached_statements, uri);
Py_DECREF(database);
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
Py_DECREF(isolation_level);
Py_XDECREF(database);
Py_XDECREF(obj_timeout);
Py_XDECREF(obj_detect_types);
Py_XDECREF(obj_check_same_thread);
Py_XDECREF(obj_cached_statements);
Py_XDECREF(obj_uri);
return result;
return res;
}

/*[clinic input]
Expand Down