-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
plugin: debuggingrelated to the debugging builtin pluginrelated to the debugging builtin plugintype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch
Description
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
- CPython github issue for supporting jumping between chained exception in Pdb: Support to jump between chained exception in Pdb python/cpython#106670
steinitzu
Metadata
Metadata
Assignees
Labels
plugin: debuggingrelated to the debugging builtin pluginrelated to the debugging builtin plugintype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch