inducer / pudb

Full-screen console debugger for Python
https://documen.tician.de/pudb/
Other
3k stars 230 forks source link

Show chained exceptions in the stack in exception handling mode #335

Open asmeurer opened 5 years ago

asmeurer commented 5 years ago

Kind of surprised this hasn't come up before. Take for example:

def test():
    try:
        test2()
    except:
        raise ValueError("Chained exception")

def test2():
    raise RuntimeError("First exception")

import pudb; pudb.set_trace()

test()

If you run over test, then go to the location of the exception, you can only go to the ValueError in the stack. You can't move up to the RuntimeError. Note that this would only work in Python 3, because Python 2 doesn't keep track of chained exceptions.

Ideally the stack should treat each chained exception as a higher stack frame, perhaps with some kind of marker to indicate the frames where an exception is raised.

I've no idea how hard this is to fix.