-
Notifications
You must be signed in to change notification settings - Fork 187
Description
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).
https://docs.python.org/3/library/exceptions.html#BaseException
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.
https://docs.python.org/3/library/exceptions.html#SystemExit
There are only three other Exceptions that inherit from exception.BaseException, not counting exception.Exception, which does fall under the category of "Uncaught Exceptions":
BaseException
├── BaseExceptionGroup
├── GeneratorExit
├── KeyboardInterrupt
├── SystemExit
└── Exception
https://docs.python.org/3/library/exceptions.html#exception-hierarchy
exception KeyboardInterrupt
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.
exception GeneratorExit
Raised when a generator or coroutine is closed; see generator.close() and coroutine.close(). It directly inherits from BaseException instead of Exception since it is technically not an error.

