Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

using pdb and catching exception

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


emailamit at gmail

Dec 1, 2007, 3:02 PM

Post #1 of 6 (188 views)
Permalink
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
--
http://mail.python.org/mailman/listinfo/python-list


frank at chagford

Dec 1, 2007, 11:14 PM

Post #2 of 6 (178 views)
Permalink
Re: using pdb and catching exception [In reply to]

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
--
http://mail.python.org/mailman/listinfo/python-list


emailamit at gmail

Dec 3, 2007, 11:10 AM

Post #3 of 6 (174 views)
Permalink
Re: using pdb and catching exception [In reply to]

On Dec 1, 11:14 pm, Frank Millman <fr...@chagford.com> wrote:
> 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)
--
http://mail.python.org/mailman/listinfo/python-list


emailamit at gmail

Dec 3, 2007, 3:36 PM

Post #4 of 6 (174 views)
Permalink
Re: using pdb and catching exception [In reply to]

On Dec 3, 11:10 am, Amit Gupta <emaila...@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?
--
http://mail.python.org/mailman/listinfo/python-list


deets at nospam

Dec 4, 2007, 2:10 PM

Post #5 of 6 (170 views)
Permalink
Re: using pdb and catching exception [In reply to]

Amit Gupta schrieb:
> On Dec 3, 11:10 am, Amit Gupta <emaila...@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
--
http://mail.python.org/mailman/listinfo/python-list


rocky at panix

Dec 6, 2007, 3:07 PM

Post #6 of 6 (170 views)
Permalink
Re: using pdb and catching exception [In reply to]

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" <deets [at] nospam> writes:

> 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
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.