This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Add "capture_output=True" option to
Type: enhancement Stage: commit review
Components: Versions:
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: barry, bbayles, gregory.p.smith, ncoghlan
Priority: normal Keywords: patch

Created on 2017-11-21 06:13 by ncoghlan, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5149 merged bbayles, 2018-01-11 13:51
PR 8374 merged and800, 2018-08-09 17:30
PR 8720 merged miss-islington, 2018-08-09 22:02
Messages (4)
msg306627 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2017-11-21 06:13
I'm hesitant to suggest adding yet-another-option to any subprocess API, but I'm thinking it may be worth it in this case.

The idea is to make it possible to replace:

    result =, stdout=PIPE, stderr=PIPE)


    result =, capture_output=True)

That way, it would be possible for the raw stdin/stdout/stderr parameters to be treated as low level implementation details most of the time, since the most common configurations would be:

    # Use parent's stdin/stdout/stderr
    result = 
    # Use pipe for stdin, use parent's stdout/stderr
    result =, input=data)
    # Use parent's stdin, use pipe for stdout/stderr
    result =, capture_output=True) 
    # Use pipe for stdin/stdout/stderr
    result =, input=data, capture_output=True)
msg306643 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2017-11-21 14:25
Yeah, I find it pretty common to set both stdout and stderr to PIPE, but I'm with you in hesitating to add YAO to the subprocess API.  If you do move forward with this though, I think capture_output would have to be mutually exclusive to stdout and stderr.  You should not be allowed to provide either of the latter two if the former is given.
msg311243 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2018-01-30 06:40
New changeset ce0f33d04528fcafc673a8707871f8430d8f7ce8 by Gregory P. Smith (Bo Bayles) in branch 'master':
bpo-32102 Add "capture_output=True" to (GH-5149)
msg311244 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2018-01-30 06:43
Thanks Bo.  I agree with Nick, this is a readability win for a common annoying to type otherwise case.
Date User Action Args
2022-04-11 14:58:54adminsetgithub: 76283
2018-08-09 22:02:59miss-islingtonsetpull_requests: + pull_request8205
2018-08-09 17:30:35and800setpull_requests: + pull_request8204
2018-01-30 06:43:14gregory.p.smithsetstatus: open -> closed
resolution: fixed
messages: + msg311244

stage: patch review -> commit review
2018-01-30 06:40:41gregory.p.smithsetmessages: + msg311243
2018-01-30 06:19:40gregory.p.smithsetassignee: gregory.p.smith
2018-01-23 03:02:15bbaylessetnosy: + bbayles
2018-01-11 13:51:15bbaylessetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request5015
2017-11-21 14:25:37barrysetnosy: + barry
messages: + msg306643
2017-11-21 06:13:47ncoghlancreate