Skip to content

ipdb: support for chained exceptions #13982

@mlucool

Description

@mlucool

This is a common pattern to enrich an exception with more information:

def foo(x):
    try:
        bar(x)
    except Exception as e:
        raise ValueError("foo(): bar failed") from e
def bar(x):
    1/x

This is common when a second exception occurs during exception handling:

def foo(x):
    try:
        bar(x)
    except Exception as e:
        raise ValueError("some other error")
def bar(x):
    1/x

In both cases, ipdb (and pdb) wont let us step up the stack from to find the error in bar. While python 3.11 has Exception.add_note, there will continue to be lots of code using the methods above (and its not always practical to use this).

Example:
image

Can we enhance ipdb to handle both cases?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions