From 5bdbf7bb3c73188432e25c10106d6f0559fc2112 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sun, 7 Apr 2024 00:46:30 +0200 Subject: [PATCH 1/3] Don't test load ext stuff since we cannot skip it conditionally --- Doc/library/sqlite3.rst | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index b17ac19535df00..738ed888c2d2e2 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1068,13 +1068,10 @@ Connection objects .. versionchanged:: 3.10 Added the ``sqlite3.enable_load_extension`` auditing event. - .. testsetup:: sqlite3.loadext + .. We cannot doctest the load extension API, since there is no convenient + way to skip it. - import sqlite3 - con = sqlite3.connect(":memory:") - - .. testcode:: sqlite3.loadext - :skipif: True # not testable at the moment + .. code-block:: con.enable_load_extension(True) @@ -1098,14 +1095,6 @@ Connection objects for row in con.execute("SELECT rowid, name, ingredients FROM recipe WHERE name MATCH 'pie'"): print(row) - con.close() - - .. testoutput:: sqlite3.loadext - :hide: - - (2, 'broccoli pie', 'broccoli cheese onions flour') - (3, 'pumpkin pie', 'pumpkin sugar flour butter') - .. method:: load_extension(path, /, *, entrypoint=None) Load an SQLite extension from a shared library. From df1cb9444a4bfba14299360b9c1292b3994cb2d4 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sun, 7 Apr 2024 00:46:55 +0200 Subject: [PATCH 2/3] Remove silly example of sys.unraisablehook --- Doc/library/sqlite3.rst | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 738ed888c2d2e2..d05f0216004fe4 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -394,29 +394,12 @@ Module functions will get tracebacks from callbacks on :data:`sys.stderr`. Use ``False`` to disable the feature again. - Register an :func:`unraisable hook handler ` for an - improved debug experience: - - .. testsetup:: sqlite3.trace - - import sqlite3 + .. note:: - .. doctest:: sqlite3.trace - - >>> sqlite3.enable_callback_tracebacks(True) - >>> con = sqlite3.connect(":memory:") - >>> def evil_trace(stmt): - ... 5/0 - ... - >>> con.set_trace_callback(evil_trace) - >>> def debug(unraisable): - ... print(f"{unraisable.exc_value!r} in callback {unraisable.object.__name__}") - ... print(f"Error message: {unraisable.err_msg}") - >>> import sys - >>> sys.unraisablehook = debug - >>> cur = con.execute("SELECT 1") - ZeroDivisionError('division by zero') in callback evil_trace - Error message: None + Exceptions that are raised in user-defined function callbacks are + raised as unraisable exceptions. + Use an :func:`unraisable hook handler ` for + introspection of the failed callback. .. function:: register_adapter(type, adapter, /) From 9e4cceb48596ef97fcd814cc8c8cf85dca9c42e5 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 8 Apr 2024 09:54:25 +0200 Subject: [PATCH 3/3] Update Doc/library/sqlite3.rst --- Doc/library/sqlite3.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index d05f0216004fe4..9b857b068388d6 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -396,8 +396,7 @@ Module functions .. note:: - Exceptions that are raised in user-defined function callbacks are - raised as unraisable exceptions. + Errors in user-defined function callbacks are logged as unraisable exceptions. Use an :func:`unraisable hook handler ` for introspection of the failed callback.