mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-44491: Allow clearing the sqlite3 authoriser callback (GH-26863)
This commit is contained in:
parent
18ba1ff6a4
commit
b19f455339
6 changed files with 33 additions and 6 deletions
|
@ -1053,20 +1053,24 @@ pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
|
|||
PyObject *authorizer_cb)
|
||||
/*[clinic end generated code: output=f18ba575d788b35c input=df079724c020d2f2]*/
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = sqlite3_set_authorizer(self->db, _authorizer_callback, (void*)authorizer_cb);
|
||||
int rc;
|
||||
if (authorizer_cb == Py_None) {
|
||||
rc = sqlite3_set_authorizer(self->db, NULL, NULL);
|
||||
Py_XSETREF(self->function_pinboard_authorizer_cb, NULL);
|
||||
}
|
||||
else {
|
||||
Py_INCREF(authorizer_cb);
|
||||
Py_XSETREF(self->function_pinboard_authorizer_cb, authorizer_cb);
|
||||
rc = sqlite3_set_authorizer(self->db, _authorizer_callback, authorizer_cb);
|
||||
}
|
||||
if (rc != SQLITE_OK) {
|
||||
PyErr_SetString(pysqlite_OperationalError, "Error setting authorizer callback");
|
||||
Py_XSETREF(self->function_pinboard_authorizer_cb, NULL);
|
||||
return NULL;
|
||||
} else {
|
||||
Py_INCREF(authorizer_cb);
|
||||
Py_XSETREF(self->function_pinboard_authorizer_cb, authorizer_cb);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue