summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-05-02 21:25:17 (GMT)
committerGitHub <noreply@github.com>2021-05-02 21:25:17 (GMT)
commitc96cc089f60d2bf7e003c27413c3239ee9de2990 (patch)
treed93d46ef410fdda18eab4d3a75cc55af541387e9 /Modules
parent37e0c7850de902179b28f1378fbbc38a5ed3628c (diff)
downloadcpython-c96cc089f60d2bf7e003c27413c3239ee9de2990.zip
cpython-c96cc089f60d2bf7e003c27413c3239ee9de2990.tar.gz
cpython-c96cc089f60d2bf7e003c27413c3239ee9de2990.tar.bz2
bpo-43434: Move sqlite3.connect audit events to sqlite3.Connection.__init__ (GH-25818)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_sqlite/connection.c8
-rw-r--r--Modules/_sqlite/module.c9
2 files changed, 8 insertions, 9 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 5f8e41b..fb54112 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -86,6 +86,10 @@ pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,
return -1;
}
+ if (PySys_Audit("sqlite3.connect", "O", database_obj) < 0) {
+ return -1;
+ }
+
database = PyBytes_AsString(database_obj);
self->initialized = 1;
@@ -179,6 +183,10 @@ pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,
self->ProgrammingError = pysqlite_ProgrammingError;
self->NotSupportedError = pysqlite_NotSupportedError;
+ if (PySys_Audit("sqlite3.connect/handle", "O", self) < 0) {
+ return -1;
+ }
+
return 0;
}
diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
index 2f323fc..3249946 100644
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -91,20 +91,11 @@ static PyObject* module_connect(PyObject* self, PyObject* args, PyObject*
factory = (PyObject*)pysqlite_ConnectionType;
}
- if (PySys_Audit("sqlite3.connect", "O", database) < 0) {
- return NULL;
- }
-
result = PyObject_Call(factory, args, kwargs);
if (result == NULL) {
return NULL;
}
- if (PySys_Audit("sqlite3.connect/handle", "O", self) < 0) {
- Py_DECREF(result);
- return NULL;
- }
-
return result;
}