3

Closed

'Continue' after debugging an exception traces the stack

description

Normally the debugger doesn't break on a user-unhandled exception (another issue?), but breaks fine when the 'Thrown' box in exceptions is selected.

Pressing 'Continue' (or F5) after the exception is thrown will break again at each stack frame until reaching the final handler, whether that's the one provided by debugger.py/Python itself or in the user's code.

My expected behaviour would be to break once where the exception is raised; selecting "continue" skips straight to the final handler.

(Tested with both an AssertionError from assert and a ValueError from raise using CPython 2.7.)
Closed Feb 28 at 7:53 PM by Zooba
Fixed ages ago.

comments

dinov wrote May 20, 2011 at 11:08 PM

Currently we cannot know whether an exception is handled or not, let alone know the handling frame, which is the reason you see this behavior. If we worked on a way to do this (which it might not be possible to do perfectly) then we could also display the unhandled exceptions to the user.

Zooba wrote May 21, 2011 at 1:46 AM

It's almost certainly not possible to do it efficiently. Since the exception can be caught immediately, it should be possible to traverse the stack frame manually to find a handler. Alternatively, the debugger could only break in on otherwise unhandled exceptions (rather than just the current handler) and use the traceback to find the place in the source, though this presumably doesn't include any variable context.

It should at least be possible to ignore exceptions that have an except block in the current frame.

A cache on the exception value id may be a cheap way to prevent multiple breaks for the same exception.

Zooba wrote Nov 5, 2011 at 2:20 AM

This is fixed now, at least for user-unhandled exceptions and maybe both (we check the size of the traceback object that gets built up as the stack unwinds). I have no objections to closing this issue.