mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-43762: Add audit events for loading of sqlite3 extensions (GH-25246)
This commit is contained in:
parent
52cd6d5e1b
commit
7244c0060d
7 changed files with 86 additions and 0 deletions
|
@ -359,6 +359,27 @@ def test_http_client():
|
|||
conn.close()
|
||||
|
||||
|
||||
def test_sqlite3():
|
||||
import sqlite3
|
||||
|
||||
def hook(event, *args):
|
||||
if event.startswith("sqlite3."):
|
||||
print(event, *args)
|
||||
|
||||
sys.addaudithook(hook)
|
||||
cx = sqlite3.connect(":memory:")
|
||||
|
||||
# Configured without --enable-loadable-sqlite-extensions
|
||||
if hasattr(sqlite3.Connection, "enable_load_extension"):
|
||||
cx.enable_load_extension(False)
|
||||
try:
|
||||
cx.load_extension("test")
|
||||
except sqlite3.OperationalError:
|
||||
pass
|
||||
else:
|
||||
raise RuntimeError("Expected sqlite3.load_extension to fail")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from test.support import suppress_msvcrt_asserts
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue