Visitar URL original
bpo-40956: Convert _sqlite3.Connection to Argument Clinic, part 1 of 2 by erlend-aasland · Pull Request #23341 · python/cpython · GitHub
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
Prev Previous commit
Next Next commit
Address review: set_authorizer() should also accept keyword arguments
  • Loading branch information
Erlend E. Aasland
Erlend E. Aasland committed Dec 18, 2020
commit feec909626c24e221756f6b3154933800be769a8
30 changes: 27 additions & 3 deletions Modules/_sqlite/clinic/connection.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,37 @@ pysqlite_connection_create_aggregate(pysqlite_Connection *self, PyObject *const
}

PyDoc_STRVAR(pysqlite_connection_set_authorizer__doc__,
"set_authorizer($self, authorizer_callback, /)\n"
"set_authorizer($self, /, authorizer_callback)\n"
"--\n"
"\n"
"Sets authorizer callback. Non-standard.");

#define PYSQLITE_CONNECTION_SET_AUTHORIZER_METHODDEF \
{"set_authorizer", (PyCFunction)pysqlite_connection_set_authorizer, METH_O, pysqlite_connection_set_authorizer__doc__},
{"set_authorizer", (PyCFunction)(void(*)(void))pysqlite_connection_set_authorizer, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_authorizer__doc__},

static PyObject *
pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
PyObject *authorizer_cb);

static PyObject *
pysqlite_connection_set_authorizer(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"authorizer_callback", NULL};
static _PyArg_Parser _parser = {NULL, _keywords, "set_authorizer", 0};
PyObject *argsbuf[1];
PyObject *authorizer_cb;

args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
if (!args) {
goto exit;
}
authorizer_cb = args[0];
return_value = pysqlite_connection_set_authorizer_impl(self, authorizer_cb);

exit:
return return_value;
}

PyDoc_STRVAR(pysqlite_connection_set_progress_handler__doc__,
"set_progress_handler($self, /, progress_handler, n)\n"
Expand Down Expand Up @@ -463,4 +487,4 @@ pysqlite_connection_exit(pysqlite_Connection *self, PyObject *const *args, Py_ss
#ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
#define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
#endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */
/*[clinic end generated code: output=773cc0362d80078c input=a9049054013a1b77]*/
/*[clinic end generated code: output=e14085c0abc0a407 input=a9049054013a1b77]*/
7 changes: 3 additions & 4 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,15 +1021,14 @@ static void _trace_callback(void* user_arg, const char* statement_string)
_sqlite3.Connection.set_authorizer as pysqlite_connection_set_authorizer

authorizer_callback as authorizer_cb: object
Comment thread
erlend-aasland marked this conversation as resolved.
/

Sets authorizer callback. Non-standard.
[clinic start generated code]*/

static PyObject *
pysqlite_connection_set_authorizer(pysqlite_Connection *self,
PyObject *authorizer_cb)
/*[clinic end generated code: output=4f2f5f3f84d99092 input=1c43aa0c0939fec4]*/
pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
PyObject *authorizer_cb)
/*[clinic end generated code: output=f18ba575d788b35c input=df079724c020d2f2]*/
{
int rc;

Expand Down