Home » Support » Index of All Documentation » Wing IDE Reference Manual » Debugger »

By default, Wing's debugger stops at exceptions when they would be printed by the Python interpreter or when they are logged with logging.exception. Wing will also stop on all AssertionError exceptions, whether or not they are printed or logged, since these usually indicate a program error even if they are handled.

The Debugger > Exceptions preference group can be used to control how Wing approaches exception reporting. This includes the following preferences.

Exception Reporting Mode

The overall strategy for identifying and reporting exceptions is configured with the Report Exceptions preference. The following choices are available:

When Printed (default) -- The debugger will stop on exceptions at the time that they would have been printed out by the Python interpreter.

For code with catch-all exceptions written in Python, Wing may fail to report unexpected exceptions if the handlers do not print the exception. In this case, it is best to rewrite the catch-all handlers as described in Trouble-shooting Failure to Stop on Exceptions.

In this exception handling mode, any code in finally clauses, except clauses that reraise the exception, and with statement cleanup routines will be executed before the debugger stops because they execute before the traceback is printed.

Always Immediately -- The debugger will stop at every single exception immediately when it is raised. In most code this will be very often, since exceptions may be used internally to handle normal, acceptible runtime conditions. As a result, this option is usually only useful after already running close to code that requires further examination.

At Process Termination -- In this case, the debugger will make a best effort to stop and report exceptions that actually lead to process termination. This occurs just before or sometimes just after the process is terminated. The exception is also printed to stderr, as it would be when running outside of the debugger.

When working with an Externally Launched Debug Process , the At Process Termination mode may not be able to stop the debug process before it exits, and in some cases may even fail to show any post-mortem traceback at all (except as printed to stderr in the debug process).

Similarly, when working with wxPython, PyGTK, and similar environments that include a catch-all exception handler in C/C++ code, the At Process Termination mode will fail to report any unexpected exceptions occurring during the main loop because those exceptions do not actually lead to process termination.

Immediately if Appear Unhandled -- The debugger will attempt to detect unhandled exceptions as they are raised in your debug process, making it possible to view the program state that led to the exception and to step through subsequently reached finally clauses. This is done by looking up the stack for exception handlers written in Python, and reporting only exceptions for which there is no matching handler.

Because of changes in the Python implementation, this mode no longer works in Python versions 2.7+ and 3.0+.

The Immediately if Appear Unhandled mode works well with wxPython, PyGTK, and in most other code where unexpected exceptions either lead to program termination or are handled by catch-all exception handlers written in C/C++ extension module code.

In some cases, Wing's unhandled exception detector can report normal handled exceptions that are not seen outside of the debugger. This occurs when the exceptions are handled in C/C++ extension module code. Wing can be trained to ignore these by checking the Ignore this exception location check box in the debugger's Exception tool. Ignored exceptions are still reported if they actually lead to program termination, and your selection is remembered in your project file so only needs to be made once. Use Clear Ignored Exceptions from the Debug menu at any time to reset the ignore list to blank.

Reporting Logged Exceptions

The Report Logged Exceptions in When Printed Mode preference controls whether exceptions that are not printed but that are logged with a call to logging.exception will be reported by the default When Printed exception reporting mode. This preference is ignored in other exception reporting modes.

Exception Type Filters

The Never Report and Always Report preferences can be used to specify that certain exception types should never be reported at all, or always reported regardless of whether they are printed or logged. For example, by default Wing will never stop on SystemExit or GeneratorExit since these occur during normal program behavior, and Wing will always stop on AssertionError since this usually indicates a bug in code even if it is handled.

In some code, adding NameError or AttributeError to the Always Report list may help uncover bugs; however, this may not work if these are treated as normal expected exceptions by the authors of the code and there are too many such cases to ignore them with the Ignore this exception location checkbox in the Exceptions tool.

« 12.11. Debugging Multi-threaded CodeTable of Contents12.13. Running Without Debug »

Managing Exceptions