[wingide-users] Auto-launching wing on exception
Wingware Support
support at wingware.com
Wed Sep 27 19:13:52 MDT 2006
On Wed, 27 Sep 2006, Tony Cappellini wrote:
> Changing it to this, makes it work with the pywin debugge, which is only
> marginally better than pdb.
>
> # python cookbook recipe
> import sys
>
> def info(type, value, tb):
> if hasattr(sys, 'ps1') or not sys.stderr.isatty():
> # we are in interactive mode or we don't have a tty-like
> # device, so we call the default hook
> sys.__excepthook__(type, value, tb)
> else:
> import traceback
> import pywin.debugger
> # instead of: import pdb pdb.pm() use: import pywin.debugger
> pywin.debugger.pm()
> # we are NOT in interactive mode, print the exception...
> traceback.print_exception(type, value, tb)
> print
> # ...then start the debugger in post-mortem mode.
> pywin.debugger.pm()
>
> sys.excepthook = info
>
>
>
> Does wing have a mechanism to launch it at the point of the exception, if it
> is not already running?
You can craft a similar mechanism as above with the following
debugger calls:
import wingdbstub
wingdbstub.debugger.Break()
You'll need to copy wingdbstub.py out of your Wing installation
so it is found and click on the bug icon in the lower left of the
main window to Enable Passive Listen.
However, this doesn't show the traceback in the Exceptions tool
so it's not quite the same. You'll need to inspect things
manually, probably best via the Debug Probe.
(I tried just adding 'raise type, value, tb' but it's apparently
too late in the termination proces to do that; we would need to
add some more debugger API to call with the traceback info to
have this work exactly the same way as the recipes)
If you can run in the debugger and only want to see exceptions at
termination, another option is to set the Debugger / Exceptions /
Report Exceptions preference to At Process Termination. It's not
quite the same internally but similar to modifying sys.excepthook
as far as when things get reported.
Stephan Deibel
--
Wingware
Wing IDE for Python
Advancing Software Development
www.wingware.com
More information about the wingide-users
mailing list