]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-111726: Remove some doctests from sqlite3 docs (GH-117623) (#117625)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 8 Apr 2024 08:18:55 +0000 (10:18 +0200)
committerGitHub <noreply@github.com>
Mon, 8 Apr 2024 08:18:55 +0000 (08:18 +0000)
* remove load extension doctest since we cannot skip it conditionally
* remove sys.unraisablehook example; using unraisable hooks is not "an
  improved debug experience"

(cherry picked from commit e338e1a4ec5e43a02447f4ec80320d7fc12b3ed4)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Doc/library/sqlite3.rst

index 541eb95094fefac44fa9613521f4981ee9865600..8a33bc7b2bbf93743898fc171165525011a9df74 100644 (file)
@@ -388,29 +388,11 @@ Module functions
    will get tracebacks from callbacks on :data:`sys.stderr`. Use ``False``
    to disable the feature again.
 
-   Register an :func:`unraisable hook handler <sys.unraisablehook>` 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
+      Errors in user-defined function callbacks are logged as unraisable exceptions.
+      Use an :func:`unraisable hook handler <sys.unraisablehook>` for
+      introspection of the failed callback.
 
 .. function:: register_adapter(type, adapter, /)
 
@@ -1037,13 +1019,10 @@ Connection objects
       .. versionchanged:: 3.10
          Added the ``sqlite3.enable_load_extension`` auditing event.
 
-      .. testsetup:: sqlite3.loadext
-
-         import sqlite3
-         con = sqlite3.connect(":memory:")
+      .. We cannot doctest the load extension API, since there is no convenient
+         way to skip it.
 
-      .. testcode:: sqlite3.loadext
-         :skipif: True  # not testable at the moment
+      .. code-block::
 
          con.enable_load_extension(True)
 
@@ -1067,14 +1046,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.