Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 11 additions & 8 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,21 @@ static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self);
static PyObject *
new_statement_cache(pysqlite_Connection *self, int maxsize)
{
PyObject *args[] = { PyLong_FromLong(maxsize), };
if (args[0] == NULL) {
PyObject *args[] = { NULL, PyLong_FromLong(maxsize), };
if (args[1] == NULL) {
return NULL;
}
PyObject *lru_cache = self->state->lru_cache;
PyObject *inner = PyObject_Vectorcall(lru_cache, args, 1, NULL);
Py_DECREF(args[0]);
PyObject *inner = PyObject_Vectorcall(
lru_cache, args + 1, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please break lines according to PEP 7? I'm striving to keep all sqlite3 changes PEP 7 compliant :)
Ditto for the other calls.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is, either:

Suggested change
PyObject *inner = PyObject_Vectorcall(
lru_cache, args + 1, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
PyObject *inner = PyObject_Vectorcall(lru_cache, args + 1,
1 | PY_VECTORCALL_ARGUMENTS_OFFSET,
NULL);

or:

Suggested change
PyObject *inner = PyObject_Vectorcall(
lru_cache, args + 1, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
size_t nargs = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET;
PyObject *inner = PyObject_Vectorcall(lru_cache, args + 1, nargs, NULL);

Py_DECREF(args[1]);
if (inner == NULL) {
return NULL;
}

args[0] = (PyObject *)self; // Borrowed ref.
PyObject *res = PyObject_Vectorcall(inner, args, 1, NULL);
args[1] = (PyObject *)self; // Borrowed ref.
PyObject *res = PyObject_Vectorcall(
inner, args + 1, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
Py_DECREF(inner);
return res;
}
Expand Down Expand Up @@ -1482,8 +1484,9 @@ pysqlite_collation_callback(

callback_context *ctx = (callback_context *)context;
assert(ctx != NULL);
PyObject *args[] = { string1, string2 }; // Borrowed refs.
retval = PyObject_Vectorcall(ctx->callable, args, 2, NULL);
PyObject *args[] = { NULL, string1, string2 }; // Borrowed refs.
retval = PyObject_Vectorcall(
ctx->callable, args + 1, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
if (retval == NULL) {
/* execution failed */
goto finally;
Expand Down
5 changes: 3 additions & 2 deletions Modules/_sqlite/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,10 @@ begin_transaction(pysqlite_Connection *self)
static PyObject *
get_statement_from_cache(pysqlite_Cursor *self, PyObject *operation)
{
PyObject *args[] = { operation, };
PyObject *args[] = { NULL, operation, };
Comment thread
encukou marked this conversation as resolved.
Outdated
PyObject *cache = self->connection->statement_cache;
return PyObject_Vectorcall(cache, args, 1, NULL);
return PyObject_Vectorcall(
cache, args + 1, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
}

static PyObject *
Expand Down