print(event, *args)
sys.addaudithook(hook)
- cx = sqlite3.connect(":memory:")
+ cx1 = sqlite3.connect(":memory:")
+ cx2 = sqlite3.Connection(":memory:")
# Configured without --enable-loadable-sqlite-extensions
if hasattr(sqlite3.Connection, "enable_load_extension"):
- cx.enable_load_extension(False)
+ cx1.enable_load_extension(False)
try:
- cx.load_extension("test")
+ cx1.load_extension("test")
except sqlite3.OperationalError:
pass
else:
if support.verbose:
print(*events, sep='\n')
actual = [ev[0] for ev in events]
- expected = ["sqlite3.connect", "sqlite3.connect/handle"]
+ expected = ["sqlite3.connect", "sqlite3.connect/handle"] * 2
if hasattr(sqlite3.Connection, "enable_load_extension"):
expected += [
--- /dev/null
+Creating :class:`sqlite3.Connection` objects now also produces
+``sqlite3.connect`` and ``sqlite3.connect/handle`` :ref:`auditing events
+<auditing>`. Previously these events were only produced by
+:func:`sqlite3.connect` calls. Patch by Erlend E. Aasland.
return -1;
}
+ if (PySys_Audit("sqlite3.connect", "O", database_obj) < 0) {
+ return -1;
+ }
+
database = PyBytes_AsString(database_obj);
self->initialized = 1;
self->ProgrammingError = pysqlite_ProgrammingError;
self->NotSupportedError = pysqlite_NotSupportedError;
+ if (PySys_Audit("sqlite3.connect/handle", "O", self) < 0) {
+ return -1;
+ }
+
return 0;
}
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;
}