summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-06-24 14:35:57 (GMT)
committerGitHub <noreply@github.com>2021-06-24 14:35:57 (GMT)
commitb19f45533942e4ad7ddf9d2d94f8b87c6f746bce (patch)
treebec9f6276d7a24488de0614d64922c4314ffa8a4 /Modules
parent18ba1ff6a4eb284aefb8d157d5e574d8326a395d (diff)
downloadcpython-b19f45533942e4ad7ddf9d2d94f8b87c6f746bce.zip
cpython-b19f45533942e4ad7ddf9d2d94f8b87c6f746bce.tar.gz
cpython-b19f45533942e4ad7ddf9d2d94f8b87c6f746bce.tar.bz2
bpo-44491: Allow clearing the sqlite3 authoriser callback (GH-26863)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_sqlite/connection.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 3e12679..6e7101a 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -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;
}