using pdb and catching exception

Diez B. Roggisch deets at nospam.web.de
Tue Dec 4 17:10:09 EST 2007


Amit Gupta schrieb:
> On Dec 3, 11:10 am, Amit Gupta <emaila... at gmail.com> wrote:
>>
>> Thanks Frank. But again, this results into stack-track when the
>> exception is caught. On the other hand, I would like the debug-trace
>> just before throwing the exception. As a case, I might be debugging
>> code, where the programmar forgot to handle an exception and it is
>> being caught way up in the flow (with generic catch block)
> 
> One thing that I can guess is to put a breakpoint on function "raise".
> I assume all of the exceptions are thrown by "raise" and raise is not
> a keyword, instead a function.
> 
> Will it work?

raise is a statement, not a function. So it won't work.

I do know that e.g. nose allows for dropping into pdb when a test fails. 
Maybe that works by catching the exception top-level, examining the 
stack-trace, setting a break-point, and restarting it.

Diez



More information about the Python-list mailing list