You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before creating a new issue, please check the FAQ to see if your question is answered there.
Environment data
debugpy version: 1.8.1
OS and version: Windows 11
Python version: 3.11
Using VS Code or Visual Studio: VS Code
Actual behavior
exit(1) halts the debugging session due to an "uncaught exception"
Expected behavior
The program program should exit without the debugger halting.
Exceptions that inherit from exception.BaseException should not fall under the category of "uncaught exceptions", since they are "technically not an error"1.
exception.BaseException
The base class for all built-in exceptions. It is not meant to be directly inherited by user-defined classes (for that, use Exception).
One of these exceptions is exception.SystemExit, which is called when calling exit(1).
exception SystemExit
This exception is raised by the sys.exit() function. 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. When it is not handled, the Python interpreter exits; no stack traceback is printed.
There are only three other Exceptions that inherit from exception.BaseException, not counting exception.Exception, which does fall under the category of "Uncaught Exceptions":
Raised when the user hits the interrupt key (normally Control-C or Delete). During execution, a check for interrupts is made regularly. The exception inherits from BaseException so as to not be accidentally caught by code that catches Exception and thus prevent the interpreter from exiting.
The text was updated successfully, but these errors were encountered:
danielniccoli
changed the title
Exceptions that inherit from BaseException should not be treated as Unhandled Exceptions
Exceptions that inherit from BaseException should not be treated as Uncaught Exceptions
May 23, 2024
Before creating a new issue, please check the FAQ to see if your question is answered there.
Environment data
Actual behavior
exit(1)
halts the debugging session due to an "uncaught exception"Expected behavior
The program program should exit without the debugger halting.
Exceptions that inherit from
exception.BaseException
should not fall under the category of "uncaught exceptions", since they are "technically not an error"1.https://docs.python.org/3/library/exceptions.html#BaseException
One of these exceptions is
exception.SystemExit
, which is called when callingexit(1)
.https://docs.python.org/3/library/exceptions.html#SystemExit
There are only three other Exceptions that inherit from
exception.BaseException
, not countingexception.Exception
, which does fall under the category of "Uncaught Exceptions":https://docs.python.org/3/library/exceptions.html#exception-hierarchy
Footnotes
https://docs.python.org/3/library/exceptions.html#GeneratorExit ↩
The text was updated successfully, but these errors were encountered: