mirror of
https://github.com/python/cpython.git
synced 2025-10-05 06:31:48 +00:00
bpo-43434: Move sqlite3.connect audit event to sqlite3.Connection.__init__ (GH-25818)
This commit is contained in:
parent
e60b1e150d
commit
ad73d1657c
3 changed files with 9 additions and 9 deletions
|
@ -0,0 +1,4 @@
|
||||||
|
Creating a :class:`sqlite3.Connection` object now also produces
|
||||||
|
a ``sqlite3.connect`` :ref:`auditing event <auditing>`.
|
||||||
|
Previously this event was only produced by :func:`sqlite3.connect`
|
||||||
|
calls. Patch by Erlend E. Aasland.
|
|
@ -96,6 +96,10 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PySys_Audit("sqlite3.connect", "O", database_obj) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
database = PyBytes_AsString(database_obj);
|
database = PyBytes_AsString(database_obj);
|
||||||
|
|
||||||
self->initialized = 1;
|
self->initialized = 1;
|
||||||
|
|
|
@ -71,8 +71,6 @@ static PyObject* module_connect(PyObject* self, PyObject* args, PyObject*
|
||||||
int uri = 0;
|
int uri = 0;
|
||||||
double timeout = 5.0;
|
double timeout = 5.0;
|
||||||
|
|
||||||
PyObject* result;
|
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|diOiOip", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|diOiOip", kwlist,
|
||||||
&database, &timeout, &detect_types,
|
&database, &timeout, &detect_types,
|
||||||
&isolation_level, &check_same_thread,
|
&isolation_level, &check_same_thread,
|
||||||
|
@ -85,13 +83,7 @@ static PyObject* module_connect(PyObject* self, PyObject* args, PyObject*
|
||||||
factory = (PyObject*)&pysqlite_ConnectionType;
|
factory = (PyObject*)&pysqlite_ConnectionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PySys_Audit("sqlite3.connect", "O", database) < 0) {
|
return PyObject_Call(factory, args, kwargs);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = PyObject_Call(factory, args, kwargs);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(module_connect_doc,
|
PyDoc_STRVAR(module_connect_doc,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue