From 1f3fb5f96b3f6e773b8c1b8ec5d8f7516c6860b0 Mon Sep 17 00:00:00 2001 From: Tiago Ilieve Date: Wed, 21 Aug 2024 00:02:35 -0300 Subject: [PATCH] debugger: load 'ipdb' if present * debugger: load 'ipdb' if present Transparently chooses between the IPython-enhanced 'ipdb' or the standard 'pdb'. * datasette install ipdb --------- Co-authored-by: Simon Willison --- datasette/handle_exception.py | 6 +++++- docs/contributing.rst | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/datasette/handle_exception.py b/datasette/handle_exception.py index 1a0ac979fe..96398a4c9f 100644 --- a/datasette/handle_exception.py +++ b/datasette/handle_exception.py @@ -5,9 +5,13 @@ ) from .views.base import DatasetteError from markupsafe import Markup -import pdb import traceback +try: + import ipdb as pdb +except ImportError: + import pdb + try: import rich except ImportError: diff --git a/docs/contributing.rst b/docs/contributing.rst index 45330a8347..c1268321f8 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -111,10 +111,14 @@ Debugging Any errors that occur while Datasette is running while display a stack trace on the console. -You can tell Datasette to open an interactive ``pdb`` debugger session if an error occurs using the ``--pdb`` option:: +You can tell Datasette to open an interactive ``pdb`` (or ``ipdb``, if present) debugger session if an error occurs using the ``--pdb`` option:: datasette --pdb fixtures.db +For `ipdb `__, first run this:: + + datasette install ipdb + .. _contributing_formatting: Code formatting @@ -349,4 +353,4 @@ Datasette bundles `CodeMirror `__ for the SQL editing i -p @rollup/plugin-node-resolve \ -p @rollup/plugin-terser -* Update the version reference in the ``codemirror.html`` template. \ No newline at end of file +* Update the version reference in the ``codemirror.html`` template.