Skip to content

bpo-6634: [doc] clarify that sys.exit() does not always exit the interpreter #31639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,7 @@ always available.

.. function:: exit([arg])

Exit from Python. This is implemented by raising the :exc:`SystemExit`
exception, so cleanup actions specified by finally clauses of :keyword:`try`
statements are honored, and it is possible to intercept the exit attempt at
an outer level.
Raise a :exc:`SystemExit` exception, signaling an intention to exit the interpreter.

The optional argument *arg* can be an integer giving the exit status
(defaulting to zero), or another type of object. If it is an integer, zero
Expand All @@ -469,7 +466,8 @@ always available.

Since :func:`exit` ultimately "only" raises an exception, it will only exit
the process when called from the main thread, and the exception is not
intercepted.
intercepted. Cleanup actions specified by finally clauses of :keyword:`try` statements
are honored, and it is possible to intercept the exit attempt at an outer level.

.. versionchanged:: 3.6
If an error occurs in the cleanup after the Python interpreter
Expand Down