Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3fa8fe7

Browse files
authored
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
1 parent 5927013 commit 3fa8fe7

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

Doc/library/subprocess.rst

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,14 @@ default values. The arguments that are most commonly needed are:
270270

271271
*stdin*, *stdout* and *stderr* specify the executed program's standard input,
272272
standard output and standard error file handles, respectively. Valid values
273-
are :data:`PIPE`, :data:`DEVNULL`, an existing file descriptor (a positive
274-
integer), an existing file object with a valid file descriptor, and ``None``.
275-
:data:`PIPE` indicates that a new pipe to the child should be created.
276-
:data:`DEVNULL` indicates that the special file :data:`os.devnull` will
277-
be used. With the default settings of ``None``, no redirection will occur;
278-
the child's file handles will be inherited from the parent.
279-
Additionally, *stderr* can be :data:`STDOUT`, which indicates that the
280-
stderr data from the child process should be captured into the same file
281-
handle as for *stdout*.
273+
are ``None``, :data:`PIPE`, :data:`DEVNULL`, an existing file descriptor (a
274+
positive integer), and an existing :term:`file object` with a valid file
275+
descriptor. With the default settings of ``None``, no redirection will
276+
occur. :data:`PIPE` indicates that a new pipe to the child should be
277+
created. :data:`DEVNULL` indicates that the special file :data:`os.devnull`
278+
will be used. Additionally, *stderr* can be :data:`STDOUT`, which indicates
279+
that the stderr data from the child process should be captured into the same
280+
file handle as for *stdout*.
282281

283282
.. index::
284283
single: universal newlines; subprocess module
@@ -490,15 +489,14 @@ functions.
490489

491490
*stdin*, *stdout* and *stderr* specify the executed program's standard input,
492491
standard output and standard error file handles, respectively. Valid values
493-
are :data:`PIPE`, :data:`DEVNULL`, an existing file descriptor (a positive
494-
integer), an existing :term:`file object` with a valid file descriptor,
495-
and ``None``. :data:`PIPE` indicates that a new pipe to the child should
496-
be created. :data:`DEVNULL` indicates that the special file
497-
:data:`os.devnull` will be used. With the default settings of ``None``,
498-
no redirection will occur; the child's file handles will be inherited from
499-
the parent. Additionally, *stderr* can be :data:`STDOUT`, which indicates
492+
are ``None``, :data:`PIPE`, :data:`DEVNULL`, an existing file descriptor (a
493+
positive integer), and an existing :term:`file object` with a valid file
494+
descriptor. With the default settings of ``None``, no redirection will
495+
occur. :data:`PIPE` indicates that a new pipe to the child should be
496+
created. :data:`DEVNULL` indicates that the special file :data:`os.devnull`
497+
will be used. Additionally, *stderr* can be :data:`STDOUT`, which indicates
500498
that the stderr data from the applications should be captured into the same
501-
file handle as for stdout.
499+
file handle as for *stdout*.
502500

503501
If *preexec_fn* is set to a callable object, this object will be called in the
504502
child process just before the child is executed.

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ Aaron Hill
747747
Joel Hillacre
748748
Richie Hindle
749749
Konrad Hinsen
750+
Richard Hoberecht
750751
David Hobley
751752
Tim Hochberg
752753
Benjamin Hodgson
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Reword :mod:`subprocess` to emphasize default behavior of *stdin*, *stdout*,
2+
and *stderr* arguments. Remove inaccurate statement about child file handle
3+
inheritance.

0 commit comments

Comments
 (0)