@@ -498,17 +498,8 @@ Initializing and finalizing the interpreter
498
498
strings other than those passed in (however, the contents of the strings
499
499
pointed to by the argument list are not modified).
500
500
501
- The return value will be ``0`` if the interpreter exits normally (i.e.,
502
- without an exception), ``1`` if the interpreter exits due to an exception,
503
- or ``2`` if the argument list does not represent a valid Python command
504
- line.
505
-
506
- Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
507
- function will not return ``1``, but exit the process, as long as
508
- ``Py_InspectFlag`` is not set. If ``Py_InspectFlag`` is set, execution will
509
- drop into the interactive Python prompt, at which point a second otherwise
510
- unhandled :exc:`SystemExit` will still exit the process, while any other
511
- means of exiting will set the return value as described above.
501
+ The return value is ``2`` if the argument list does not represent a valid
502
+ Python command line, and otherwise the same as :c:func:`Py_RunMain`.
512
503
513
504
In terms of the CPython runtime configuration APIs documented in the
514
505
:ref:`runtime configuration <init-config>` section (and without accounting
@@ -545,23 +536,18 @@ Initializing and finalizing the interpreter
545
536
546
537
If :c:member:`PyConfig.inspect` is not set (the default), the return value
547
538
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``.
539
+ an exception), the exit status of an unhandled :exc:`SystemExit`, or ``1``
540
+ for any other unhandled exception.
551
541
552
542
If :c:member:`PyConfig.inspect` is set (such as when the :option: `-i ` option
553
543
is used), rather than returning when the interpreter exits, execution will
554
544
instead resume in an interactive Python prompt (REPL) using the ``__main__``
555
545
module's global namespace. If the interpreter exited with an exception, it
556
546
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.
547
+ then determined by the way the *REPL session* terminates: ``0``, ``1``, or
548
+ the status of a :exc:`SystemExit`, as specified above.
549
+
550
+ This function always finalizes the Python interpreter before it returns.
565
551
566
552
See :ref:`Python Configuration <init-python-config>` for an example of a
567
553
customized Python that always runs in isolated mode using
0 commit comments