Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b706ff0

Browse filesBrowse files
authored
gh-133264: Correct documentation of how Py_Main and Py_RunMain handle SystemExit (#135337)
1 parent c87b5b2 commit b706ff0
Copy full SHA for b706ff0

File tree

Expand file treeCollapse file tree

1 file changed

+8
-22
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-22
lines changed

‎Doc/c-api/init.rst

Copy file name to clipboardExpand all lines: Doc/c-api/init.rst
+8-22Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -492,17 +492,8 @@ Initializing and finalizing the interpreter
492492
strings other than those passed in (however, the contents of the strings
493493
pointed to by the argument list are not modified).
494494
495-
The return value will be ``0`` if the interpreter exits normally (i.e.,
496-
without an exception), ``1`` if the interpreter exits due to an exception,
497-
or ``2`` if the argument list does not represent a valid Python command
498-
line.
499-
500-
Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
501-
function will not return ``1``, but exit the process, as long as
502-
``Py_InspectFlag`` is not set. If ``Py_InspectFlag`` is set, execution will
503-
drop into the interactive Python prompt, at which point a second otherwise
504-
unhandled :exc:`SystemExit` will still exit the process, while any other
505-
means of exiting will set the return value as described above.
495+
The return value is ``2`` if the argument list does not represent a valid
496+
Python command line, and otherwise the same as :c:func:`Py_RunMain`.
506497
507498
In terms of the CPython runtime configuration APIs documented in the
508499
:ref:`runtime configuration <init-config>` section (and without accounting
@@ -539,23 +530,18 @@ Initializing and finalizing the interpreter
539530
540531
If :c:member:`PyConfig.inspect` is not set (the default), the return value
541532
will be ``0`` if the interpreter exits normally (that is, without raising
542-
an exception), or ``1`` if the interpreter exits due to an exception. If an
543-
otherwise unhandled :exc:`SystemExit` is raised, the function will immediately
544-
exit the process instead of returning ``1``.
533+
an exception), the exit status of an unhandled :exc:`SystemExit`, or ``1``
534+
for any other unhandled exception.
545535
546536
If :c:member:`PyConfig.inspect` is set (such as when the :option:`-i` option
547537
is used), rather than returning when the interpreter exits, execution will
548538
instead resume in an interactive Python prompt (REPL) using the ``__main__``
549539
module's global namespace. If the interpreter exited with an exception, it
550540
is immediately raised in the REPL session. The function return value is
551-
then determined by the way the *REPL session* terminates: returning ``0``
552-
if the session terminates without raising an unhandled exception, exiting
553-
immediately for an unhandled :exc:`SystemExit`, and returning ``1`` for
554-
any other unhandled exception.
555-
556-
This function always finalizes the Python interpreter regardless of whether
557-
it returns a value or immediately exits the process due to an unhandled
558-
:exc:`SystemExit` exception.
541+
then determined by the way the *REPL session* terminates: ``0``, ``1``, or
542+
the status of a :exc:`SystemExit`, as specified above.
543+
544+
This function always finalizes the Python interpreter before it returns.
559545
560546
See :ref:`Python Configuration <init-python-config>` for an example of a
561547
customized Python that always runs in isolated mode using

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.