using pdb and catching exception

A

Amit Gupta

Py'ites

I am using pdb to check my code, and I would like to put a statement
like equivalent of "C++gdb>catch throw".

Basically, I would like debugger to start as soon as an exception is
thrown. How may I do it?


Thanks
 
F

Frank Millman

Amit said:
Py'ites

I am using pdb to check my code, and I would like to put a statement
like equivalent of "C++gdb>catch throw".

Basically, I would like debugger to start as soon as an exception is
thrown. How may I do it?


Thanks

See this post from less than a week ago.

http://tinyurl.com/2zyr7u

I think that the message from Diez B. Roggisch has what you are
looking for.

Frank Millman
 
A

Amit Gupta

See this post from less than a week ago.

http://tinyurl.com/2zyr7u

I think that the message from Diez B. Roggisch has what you are
looking for.

Frank Millman

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)
 
A

Amit Gupta

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?
 
D

Diez B. Roggisch

Amit said:
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
 
R

R. Bernstein

Just checked to see how Ruby deals with this. Both languages allow one
to register a trace functon to catch "events" like call, line, return,
exception, etc. Ruby however register an event before the raise takes
place.

It might be cool for some good person to go through the process of
making a formal suggestion this get added, etc. (unless a change like
this is already in the works).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top