diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -348,38 +348,37 @@ The following exceptions are the excepti Be sure to report the version of the Python interpreter (``sys.version``; it is also printed at the start of an interactive Python session), the exact error message (the exception's associated value) and if possible the source of the program that triggered the error. .. exception:: SystemExit - This exception is raised by the :func:`sys.exit` function. When it is not - handled, the Python interpreter exits; no stack traceback is printed. If the - associated value is an integer, it specifies the system exit status (passed - to C's :c:func:`exit` function); if it is ``None``, the exit status is zero; - if it has another type (such as a string), the object's value is printed and - the exit status is one. - - Instances have an attribute :attr:`!code` which is set to the proposed exit - status or error message (defaulting to ``None``). Also, this exception derives - directly from :exc:`BaseException` and not :exc:`Exception`, since it is not - technically an error. + This exception is raised by the :func:`sys.exit` function. It inherits from + :exc:`BaseException` instead of :exc:`Exception` so that it is not accidentally + caught by code that catches :exc:`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. + If the value passed to :func:`sys.exit` call is an integer, it specifies the + system exit status (passed to C's :c:func:`exit` function); if it is ``None``, + the exit status is zero; if it has another type (such as a string), the + object's value is printed and the exit status is one. A call to :func:`sys.exit` is translated into an exception so that clean-up handlers (:keyword:`finally` clauses of :keyword:`try` statements) can be executed, and so that a debugger can execute a script without running the risk of losing control. The :func:`os._exit` function can be used if it is absolutely positively necessary to exit immediately (for example, in the child process after a call to :func:`os.fork`). - The exception inherits from :exc:`BaseException` instead of :exc:`Exception` so - that it is not accidentally caught by code that catches :exc:`Exception`. This - allows the exception to properly propagate up and cause the interpreter to exit. + .. attribute:: code + + The exit status or error message that's passed to :func:`sys.exit` + (defaults to ``None``). .. exception:: TypeError Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the type mismatch.