From f4c62bf902f5f093fed1718d4d51fef3835899ee Mon Sep 17 00:00:00 2001 From: Tiago Ilieve Date: Mon, 6 May 2024 11:37:17 -0300 Subject: [PATCH] debugger: load 'ipdb' if present Transparently chooses between the IPython-enhanced 'ipdb' or the standard 'pdb'. --- datasette/handle_exception.py | 6 +++++- docs/contributing.rst | 4 ++-- 2 files changed, 7 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 b678e6379d..a07abcd80a 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -111,7 +111,7 @@ 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 @@ -345,4 +345,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.