There is a popular VS Code extension called debugpy with 36,761,718 installs. This extensions treats exit(1) as an uncaught exceptions and halts debugging.
There is a discussion going on about this at the debugpy repository, whether exit(1) should halt the debugger or not. I’m picking out the first and last post in the discussion:
Arguments against halting:
The program program should exit without the debugger halting.
Exceptions that inherit from
exception.BaseExceptionshould not fall under the category of “uncaught exceptions”, since they are “technically not an error”[…]
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.
Arguments for halting:
The Python documentation doesn’t say anything about how debuggers should behave, only about how user code should behave. It talks about “catching” exceptions, but debugger isn’t doing that - it is reporting them. Thus this is not an issue of conformance. Debugger is reporting exceptions, and
SystemExitis an exception. Whether to exclude it or not by default should be based on whether it makes sense for most scenarios or not. Given that a non-zero exit code is the standard way of reporting errors to the OS on all major platforms, thus it makes sense that it is reported by default.
I am curious what the Python developers thought when they designed the exception hierarchy and wrote the documentation. And if debuggers had any influence on these decisions, or not.