Skip to content

Commit 7a2e84c

Browse files
authored
bpo-33319: Clarify subprocess call docs. (GH-12508)
Clarify capturing or suppressing stdout and stderr on the old call APIs. Do not state that they are equivalent to run() calls when they are not implemented using run as that was misleading. Unlike run they cannot handle stdout or stderr being set to PIPE without a risk of deadlock.
1 parent 7c822e5 commit 7a2e84c

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Doc/library/subprocess.rst

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ compatibility with older versions, see the :ref:`call-function-trio` section.
5555
If *capture_output* is true, stdout and stderr will be captured.
5656
When used, the internal :class:`Popen` object is automatically created with
5757
``stdout=PIPE`` and ``stderr=PIPE``. The *stdout* and *stderr* arguments may
58-
not be used as well.
58+
not be supplied at the same time as *capture_output*.
5959

6060
The *timeout* argument is passed to :meth:`Popen.communicate`. If the timeout
6161
expires, the child process will be killed and waited for. The
@@ -1002,14 +1002,14 @@ calls these functions.
10021002
Run the command described by *args*. Wait for command to complete, then
10031003
return the :attr:`~Popen.returncode` attribute.
10041004

1005-
This is equivalent to::
1005+
Code needing to capture stdout or stderr should use :func:`run` instead:
10061006

10071007
run(...).returncode
10081008

1009-
(except that the *input* and *check* parameters are not supported)
1009+
To suppress stdout or stderr, supply a value of :data:`DEVNULL`.
10101010

1011-
The arguments shown above are merely the most
1012-
common ones. The full function signature is largely the
1011+
The arguments shown above are merely some common ones.
1012+
The full function signature is the
10131013
same as that of the :class:`Popen` constructor - this function passes all
10141014
supplied arguments other than *timeout* directly through to that interface.
10151015

@@ -1030,14 +1030,14 @@ calls these functions.
10301030
:exc:`CalledProcessError` object will have the return code in the
10311031
:attr:`~CalledProcessError.returncode` attribute.
10321032

1033-
This is equivalent to::
1033+
Code needing to capture stdout or stderr should use :func:`run` instead:
10341034

10351035
run(..., check=True)
10361036

1037-
(except that the *input* parameter is not supported)
1037+
To suppress stdout or stderr, supply a value of :data:`DEVNULL`.
10381038

1039-
The arguments shown above are merely the most
1040-
common ones. The full function signature is largely the
1039+
The arguments shown above are merely some common ones.
1040+
The full function signature is the
10411041
same as that of the :class:`Popen` constructor - this function passes all
10421042
supplied arguments other than *timeout* directly through to that interface.
10431043

@@ -1067,7 +1067,7 @@ calls these functions.
10671067

10681068
run(..., check=True, stdout=PIPE).stdout
10691069

1070-
The arguments shown above are merely the most common ones.
1070+
The arguments shown above are merely some common ones.
10711071
The full function signature is largely the same as that of :func:`run` -
10721072
most arguments are passed directly through to that interface.
10731073
However, explicitly passing ``input=None`` to inherit the parent's
@@ -1077,8 +1077,9 @@ calls these functions.
10771077
encoding of the output data may depend on the command being invoked, so the
10781078
decoding to text will often need to be handled at the application level.
10791079

1080-
This behaviour may be overridden by setting *universal_newlines* to
1081-
``True`` as described above in :ref:`frequently-used-arguments`.
1080+
This behaviour may be overridden by setting *text*, *encoding*, *errors*,
1081+
or *universal_newlines* to ``True`` as described in
1082+
:ref:`frequently-used-arguments` and :func:`run`.
10821083

10831084
To also capture standard error in the result, use
10841085
``stderr=subprocess.STDOUT``::

0 commit comments

Comments
 (0)