gh-88324: Clarify documentation for redirected stdout/stderr when using subprocess in Linux (#94035)

* Update description of stdout, stderr, and stdin.

Changes:
- Move the ``None`` option (which is default) to the front of the list
  of input options
- Move the ``None`` option description up to make the default behavior
  more clear (No redirection)
- Remove mention of Child File Descriptors from ``None`` option description
This commit is contained in:
richardhob 2023-01-19 23:56:13 -08:00 committed by GitHub
parent 5927013e47
commit 3fa8fe7177
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 17 deletions

View file

@ -270,15 +270,14 @@ default values. The arguments that are most commonly needed are:
*stdin*, *stdout* and *stderr* specify the executed program's standard input, *stdin*, *stdout* and *stderr* specify the executed program's standard input,
standard output and standard error file handles, respectively. Valid values standard output and standard error file handles, respectively. Valid values
are :data:`PIPE`, :data:`DEVNULL`, an existing file descriptor (a positive are ``None``, :data:`PIPE`, :data:`DEVNULL`, an existing file descriptor (a
integer), an existing file object with a valid file descriptor, and ``None``. positive integer), and an existing :term:`file object` with a valid file
:data:`PIPE` indicates that a new pipe to the child should be created. descriptor. With the default settings of ``None``, no redirection will
:data:`DEVNULL` indicates that the special file :data:`os.devnull` will occur. :data:`PIPE` indicates that a new pipe to the child should be
be used. With the default settings of ``None``, no redirection will occur; created. :data:`DEVNULL` indicates that the special file :data:`os.devnull`
the child's file handles will be inherited from the parent. will be used. Additionally, *stderr* can be :data:`STDOUT`, which indicates
Additionally, *stderr* can be :data:`STDOUT`, which indicates that the that the stderr data from the child process should be captured into the same
stderr data from the child process should be captured into the same file file handle as for *stdout*.
handle as for *stdout*.
.. index:: .. index::
single: universal newlines; subprocess module single: universal newlines; subprocess module
@ -490,15 +489,14 @@ functions.
*stdin*, *stdout* and *stderr* specify the executed program's standard input, *stdin*, *stdout* and *stderr* specify the executed program's standard input,
standard output and standard error file handles, respectively. Valid values standard output and standard error file handles, respectively. Valid values
are :data:`PIPE`, :data:`DEVNULL`, an existing file descriptor (a positive are ``None``, :data:`PIPE`, :data:`DEVNULL`, an existing file descriptor (a
integer), an existing :term:`file object` with a valid file descriptor, positive integer), and an existing :term:`file object` with a valid file
and ``None``. :data:`PIPE` indicates that a new pipe to the child should descriptor. With the default settings of ``None``, no redirection will
be created. :data:`DEVNULL` indicates that the special file occur. :data:`PIPE` indicates that a new pipe to the child should be
:data:`os.devnull` will be used. With the default settings of ``None``, created. :data:`DEVNULL` indicates that the special file :data:`os.devnull`
no redirection will occur; the child's file handles will be inherited from will be used. Additionally, *stderr* can be :data:`STDOUT`, which indicates
the parent. Additionally, *stderr* can be :data:`STDOUT`, which indicates
that the stderr data from the applications should be captured into the same that the stderr data from the applications should be captured into the same
file handle as for stdout. file handle as for *stdout*.
If *preexec_fn* is set to a callable object, this object will be called in the If *preexec_fn* is set to a callable object, this object will be called in the
child process just before the child is executed. child process just before the child is executed.

View file

@ -747,6 +747,7 @@ Aaron Hill
Joel Hillacre Joel Hillacre
Richie Hindle Richie Hindle
Konrad Hinsen Konrad Hinsen
Richard Hoberecht
David Hobley David Hobley
Tim Hochberg Tim Hochberg
Benjamin Hodgson Benjamin Hodgson

View file

@ -0,0 +1,3 @@
Reword :mod:`subprocess` to emphasize default behavior of *stdin*, *stdout*,
and *stderr* arguments. Remove inaccurate statement about child file handle
inheritance.