cpython: 64c0b4aead0f (original) (raw)
Mercurial > cpython
changeset 94926:64c0b4aead0f 3.4
Issue #23432: Remove duplicate content from SystemExit docs. Also, document SystemExit.code attribute explicitly. [#23432]
Berker Peksag berker.peksag@gmail.com | |
---|---|
date | Tue, 10 Mar 2015 14:47:15 +0200 |
parents | 50e32059a404 |
children | 5163fb8dc61f 12a857e173b7 |
files | Doc/library/exceptions.rst |
diffstat | 1 files changed, 13 insertions(+), 13 deletions(-)[+] [-] Doc/library/exceptions.rst 26 |
line wrap: on
line diff
--- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -353,18 +353,17 @@ The following exceptions are the excepti .. 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 isNone
, the exit status is zero; - if it has another type (such as a string), the object's value is printed and
- 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. The
- constructor accepts the same optional argument passed to :func:
sys.exit
. - If the value is an integer, it specifies the system exit status (passed to
- C's :c:func:
exit
function); if it isNone
, 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.
-
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 @@ -372,9 +371,10 @@ The following exceptions are the excepti 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.