Skip to content

Support navigating exceptions chains in pdb #12707

Closed

Description

@AWhetter

What's the problem this feature will solve?

If running pytest with --pdb and a chain of exceptions is raised, you can only navigate the bottom exception in the chain. You cannot hop between exceptions in the chain

Describe the solution you'd like

Python 3.13.0a1 added support for jumping between chained exception in Pdb (python/cpython@f75cefd). pdb.post_mortem and pdb.Pdb.interaction must be passed an exception object for this to work. These functions used to accept only a traceback, so that's what pytest is passing currently. If pytest passes an exception instead then exception chains can be navigated. As a proof of concept:

diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py
index 3e1463fff..578150f43 100644
--- a/src/_pytest/debugging.py
+++ b/src/_pytest/debugging.py
@@ -354,7 +354,7 @@ def _enter_pdb(
     tw.sep(">", "traceback")
     rep.toterminal(tw)
     tw.sep(">", "entering PDB")
-    tb = _postmortem_traceback(excinfo)
+    tb = excinfo.value #_postmortem_traceback(excinfo)
     rep._pdbshown = True  # type: ignore[attr-defined]
     post_mortem(tb)
     return rep

Alternative Solutions

I have not looked for alternate solutions.

Additional context

Activity

  1. added 2 commits that reference this issue on Aug 10, 2024
    c9866c8
    3844b41
  2. added a commit that references this issue on Aug 22, 2024
    7d85123
  3. added
    type: enhancementnew feature or API change, should be merged into features branch
    plugin: debuggingrelated to the debugging builtin plugin
    on Aug 23, 2024
  4. added a commit that references this issue on Sep 7, 2024
    3cc88d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: debuggingrelated to the debugging builtin plugintype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions