Stop execution while debugging

22 views
Skip to first unread message

frgoo

unread,
Jun 5, 2025, 9:34:58 AMJun 5
to PyScripter
When stopping execution by pressing the stop button on the toolbar while debugging a code block which is surrounded by a "try ... catch Exception" the code block of the catch part ist always executed.

I'm not sure if this is a problem with PyScripter or Python itself.
 
The reason seems that "bdb.BdbQuit" is raised when this happens and "BdbQuit" is inherited from "Exception" and not "BaseException" which should be different from my understanding.

Is there anything I'm missing or is this as it should be?

Regards

PyScripter

unread,
Jun 5, 2025, 9:42:15 AMJun 5
to PyScripter
BdbQuit is defined in bdb.py, which is part of the standard library, so it is not up to me to change.   

If your code is to be stopped gracefully (releasing handles etc.) then the exception handlers need to be executed.   That is how is should be.

frgoo

unread,
Jun 5, 2025, 9:51:17 AMJun 5
to PyScripter
Thanks for clarification and fast response.

I would have expected BdbQuit to be inherited from BaseException similar to SystemExit where the doc state:

It inherits from BaseException instead of Exception so that it is not accidentally caught by code that catches Exception. This allows the exception to properly propagate up and cause the interpreter to exit.

Regards

PyScripter

unread,
Jun 5, 2025, 10:07:26 AMJun 5
to PyScripter
BdbQuit is only raised by the debugger to signal that execution need to be stopped.  Unlike SystemExit, which results in your program exiting abruptly, BdbQuit causes a graceful termination of execution. PyScripter catches this exception, reports the error and allows you to continue working with the python engine, for example by viewing the values of the global variables in the Interpreter Window.
This is how the built-in python debugger is meant to work.

frgoo

unread,
Jun 5, 2025, 10:11:39 AMJun 5
to PyScripter
Think I got it now.

Thanks again for your explanation.
Reply all
Reply to author
Forward
0 new messages