[wingide-users] WingIDE does not catch exceptions with external debug and context managers

Phil Vandry vandry at TZoNE.ORG
Tue Jun 29 13:57:18 MDT 2010


I got Wing working with externally-started code using passive listening
and "import wingdbstub" but I encountered a problem when this
functionality was combined with context managers.

Sample code:

<---<---cut---<---<
#!/usr/bin/python

from __future__ import with_statement

import wingdbstub

class ContextManager(object):
    def __enter__(self):
        return self
    
    def __exit__(self, exc, value, tb):
        if exc:
            print "got exception"
        else:
            print "got none"

with ContextManager() as c:
    print 3/0
<---<---cut---<---<

When run directly from the GUI (locally), this code starts and then
halts when it encounters the ZeroDivisionError in the last line of
code.

When run remotely it just runs, prints the ZeroDivisonError and
traceback to stderr, and aborts, just as if it wasn't running under
the debugger.

If I remove the "with" statement and leave the "print 3/0"
statement at the top level, the debugger catches the exception
and stops execution, showing that statement. This proves that
the connection between the external process and Wing environment
is successfully established.

Most of the important parts of my code run under one context
manager or another which perform cleanup actions when errors are
encountered, so this means that Wing hardly ever catches errors
in my code and lets me debug them.

What am I doing wrong?

(Python 2.5.2 from Debian Lenny and Wing 3.2.9-1)

-Phil


More information about the wingide-users mailing list