ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Re: Debugging an unhandled exception?
by Fernando Perez other posts by this author
Feb 18 2003 2:26AM messages near this date
Re: HTMLParser rejects real-life tagsoup | [C API] get the stack information
Paul Rubin wrote:

>  Is there any way to launch the debugger on raising an unhandled
>  exception?


You may try ipython (http://www-hep.colorado.edu/~fperez/ipython) as your 
python interactive shell.

Under ipython, typing 'pdb' (minus the quotes) at the prompt turns on 
automatic invocation of the pdb debugger at uncaught exceptions.  Then all 
you need to do is run your scripts from within ipython (use the 'run' 
command for that).  Once you're done, you can call 'pdb' again to turn the 
feature off ('pdb' is an on/off toggle).

This gives you pdb with the stack of your code 'live', which makes it quite 
easy to debug problems. You can walk up and down the stack, print the 
values of variables, run code and call functions on them, etc.  You can't 
resume execution, but it's still quite useful.

Note that similar functionality can be added to any python session, it's 
just a matter of resetting sys.excepthook to pdb with the right mode.  For 
details (which I don't recall), see the ipython sources.

Cheers,

f.

-- 
http://mail.python.org/mailman/listinfo/python-list

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved