Skip to content

Commit 8427cb8

Browse files
committed
Correct documentation of how Py_RunMain handles SystemExit
1 parent ad2f088 commit 8427cb8

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

Doc/c-api/init.rst

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -545,23 +545,18 @@ Initializing and finalizing the interpreter
545545
546546
If :c:member:`PyConfig.inspect` is not set (the default), the return value
547547
will be ``0`` if the interpreter exits normally (that is, without raising
548-
an exception), or ``1`` if the interpreter exits due to an exception. If an
549-
otherwise unhandled :exc:`SystemExit` is raised, the function will immediately
550-
exit the process instead of returning ``1``.
548+
an exception), the corresponding exit status if there was an unhandled
549+
:exc:`SystemExit`, or ``1`` for any other unhandled exception.
551550
552551
If :c:member:`PyConfig.inspect` is set (such as when the :option:`-i` option
553552
is used), rather than returning when the interpreter exits, execution will
554553
instead resume in an interactive Python prompt (REPL) using the ``__main__``
555554
module's global namespace. If the interpreter exited with an exception, it
556555
is immediately raised in the REPL session. The function return value is
557-
then determined by the way the *REPL session* terminates: returning ``0``
558-
if the session terminates without raising an unhandled exception, exiting
559-
immediately for an unhandled :exc:`SystemExit`, and returning ``1`` for
560-
any other unhandled exception.
561-
562-
This function always finalizes the Python interpreter regardless of whether
563-
it returns a value or immediately exits the process due to an unhandled
564-
:exc:`SystemExit` exception.
556+
then determined by the way the *REPL session* terminates: ``0``, ``1``, or
557+
the status of a :exc:`SystemExit`, as specified above.
558+
559+
This function always finalizes the Python interpreter before it returns.
565560
566561
See :ref:`Python Configuration <init-python-config>` for an example of a
567562
customized Python that always runs in isolated mode using

0 commit comments

Comments
 (0)