471,316 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

using pdb and catching exception

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
Dec 1 '07 #1
5 6523


Amit Gupta wrote:
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
Dec 2 '07 #2
On Dec 1, 11:14 pm, Frank Millman <fr...@chagford.comwrote:
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)
Dec 3 '07 #3
On Dec 3, 11:10 am, Amit Gupta <emaila...@gmail.comwrote:
>

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?
Dec 3 '07 #4
Amit Gupta schrieb:
On Dec 3, 11:10 am, Amit Gupta <emaila...@gmail.comwrote:
>>
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
Dec 4 '07 #5
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).

"Diez B. Roggisch" <de***@nospam.web.dewrites:
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
Dec 6 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Adam H. Peterson | last post: by
9 posts views Thread by A. Saksena | last post: by
3 posts views Thread by Tony Johansson | last post: by
12 posts views Thread by bj7lewis | last post: by
7 posts views Thread by cmay | last post: by
8 posts views Thread by Daniel Portal | last post: by
1 post views Thread by Anonieko | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.