mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
[3.14] gh-133264: Correct documentation of how Py_Main and Py_RunMain handle SystemExit (GH-135337) (#135394)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
gh-133264: Correct documentation of how Py_Main and Py_RunMain handle SystemExit (GH-135337)
(cherry picked from commit b706ff003c
)
Co-authored-by: Malcolm Smith <smith@chaquo.com>
This commit is contained in:
parent
0e969fe843
commit
98136ddb0e
1 changed files with 7 additions and 21 deletions
|
@ -498,17 +498,8 @@ Initializing and finalizing the interpreter
|
||||||
strings other than those passed in (however, the contents of the strings
|
strings other than those passed in (however, the contents of the strings
|
||||||
pointed to by the argument list are not modified).
|
pointed to by the argument list are not modified).
|
||||||
|
|
||||||
The return value will be ``0`` if the interpreter exits normally (i.e.,
|
The return value is ``2`` if the argument list does not represent a valid
|
||||||
without an exception), ``1`` if the interpreter exits due to an exception,
|
Python command line, and otherwise the same as :c:func:`Py_RunMain`.
|
||||||
or ``2`` if the argument list does not represent a valid Python command
|
|
||||||
line.
|
|
||||||
|
|
||||||
Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
|
|
||||||
function will not return ``1``, but exit the process, as long as
|
|
||||||
``Py_InspectFlag`` is not set. If ``Py_InspectFlag`` is set, execution will
|
|
||||||
drop into the interactive Python prompt, at which point a second otherwise
|
|
||||||
unhandled :exc:`SystemExit` will still exit the process, while any other
|
|
||||||
means of exiting will set the return value as described above.
|
|
||||||
|
|
||||||
In terms of the CPython runtime configuration APIs documented in the
|
In terms of the CPython runtime configuration APIs documented in the
|
||||||
:ref:`runtime configuration <init-config>` section (and without accounting
|
:ref:`runtime configuration <init-config>` section (and without accounting
|
||||||
|
@ -545,23 +536,18 @@ Initializing and finalizing the interpreter
|
||||||
|
|
||||||
If :c:member:`PyConfig.inspect` is not set (the default), the return value
|
If :c:member:`PyConfig.inspect` is not set (the default), the return value
|
||||||
will be ``0`` if the interpreter exits normally (that is, without raising
|
will be ``0`` if the interpreter exits normally (that is, without raising
|
||||||
an exception), or ``1`` if the interpreter exits due to an exception. If an
|
an exception), the exit status of an unhandled :exc:`SystemExit`, or ``1``
|
||||||
otherwise unhandled :exc:`SystemExit` is raised, the function will immediately
|
for any other unhandled exception.
|
||||||
exit the process instead of returning ``1``.
|
|
||||||
|
|
||||||
If :c:member:`PyConfig.inspect` is set (such as when the :option:`-i` option
|
If :c:member:`PyConfig.inspect` is set (such as when the :option:`-i` option
|
||||||
is used), rather than returning when the interpreter exits, execution will
|
is used), rather than returning when the interpreter exits, execution will
|
||||||
instead resume in an interactive Python prompt (REPL) using the ``__main__``
|
instead resume in an interactive Python prompt (REPL) using the ``__main__``
|
||||||
module's global namespace. If the interpreter exited with an exception, it
|
module's global namespace. If the interpreter exited with an exception, it
|
||||||
is immediately raised in the REPL session. The function return value is
|
is immediately raised in the REPL session. The function return value is
|
||||||
then determined by the way the *REPL session* terminates: returning ``0``
|
then determined by the way the *REPL session* terminates: ``0``, ``1``, or
|
||||||
if the session terminates without raising an unhandled exception, exiting
|
the status of a :exc:`SystemExit`, as specified above.
|
||||||
immediately for an unhandled :exc:`SystemExit`, and returning ``1`` for
|
|
||||||
any other unhandled exception.
|
|
||||||
|
|
||||||
This function always finalizes the Python interpreter regardless of whether
|
This function always finalizes the Python interpreter before it returns.
|
||||||
it returns a value or immediately exits the process due to an unhandled
|
|
||||||
:exc:`SystemExit` exception.
|
|
||||||
|
|
||||||
See :ref:`Python Configuration <init-python-config>` for an example of a
|
See :ref:`Python Configuration <init-python-config>` for an example of a
|
||||||
customized Python that always runs in isolated mode using
|
customized Python that always runs in isolated mode using
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue