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: fails with capture_output=True and stderr=STDOUT
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: Joe.Borg, bbayles, gregory.p.smith, martin.panter, miss-islington, xtreak
Priority: normal Keywords: patch

Created on 2019-04-30 16:38 by Joe.Borg, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13322 merged gregory.p.smith, 2019-05-14 17:48
PR 13327 merged miss-islington, 2019-05-14 19:33
Messages (5)
msg341158 - (view) Author: Joe Borg (Joe.Borg) Date: 2019-04-30 16:38
Reading from

If you ran the process with stderr=subprocess.STDOUT, stdout and stderr will be combined in this attribute, and stderr will be None.

But, if you run `run()` with `capture_output=True`, you get the following exception:

ValueError: stdout and stderr arguments may not be used with capture_output.

So, it seems impossible to get the combined outputs of stdout and stderr with `run()`.
msg341159 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-04-30 17:02
Are you using something like below? This exception was added with ce0f33d04528fcafc673a8707871f8430d8f7ce8 (issue32102)

>>>'ls', stdout=subprocess.PIPE, capture_output=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/", line 469, in run
    raise ValueError('stdout and stderr arguments may not be used '
ValueError: stdout and stderr arguments may not be used with capture_output.

There is a note on the docs and a discussion on the issue that capture_output and stdout/stderr cannot be used at the same time.

> If capture_output is true, stdout and stderr will be captured. When used, the internal Popen object is automatically created with stdout=PIPE and stderr=PIPE. The stdout and stderr arguments may not be supplied at the same time as capture_output.
msg341169 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2019-05-01 00:01
Python 3.7 added the "capture_output" parameter, for Issue 32102. Before that change, you could use "subprocess.PIPE":
“To [capture output], pass PIPE for the ‘stdout’ and/or ‘stderr’ arguments”

Since "capture_output" was added, it looks like you can still pass "subprocess.PIPE" on your own, but the documentation now only gives subtle hints that this might be supported. This was also brought up in Issue 33319.
msg342506 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2019-05-14 19:33
New changeset e883091abf7ca84a88e956fe5202e75c53bd4128 by Gregory P. Smith in branch 'master':
bpo-36760: Clarify subprocess capture_output docs. (GH-13322)
msg342507 - (view) Author: miss-islington (miss-islington) Date: 2019-05-14 19:39
New changeset 822683238c36e15f59d289075917ff7dedb5f4e6 by Miss Islington (bot) in branch '3.7':
bpo-36760: Clarify subprocess capture_output docs. (GH-13322)
Date User Action Args
2022-04-11 14:59:14adminsetgithub: 80941
2019-05-14 19:39:23miss-islingtonsetnosy: + miss-islington
messages: + msg342507
2019-05-14 19:34:23gregory.p.smithsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-05-14 19:33:39miss-islingtonsetpull_requests: + pull_request13239
2019-05-14 19:33:38gregory.p.smithsetmessages: + msg342506
2019-05-14 17:48:58gregory.p.smithsetassignee: gregory.p.smith
components: + Documentation, - Library (Lib)
versions: + Python 3.8
2019-05-14 17:48:01gregory.p.smithsetkeywords: + patch
stage: patch review
pull_requests: + pull_request13233
2019-05-01 00:01:41martin.pantersetnosy: + martin.panter, bbayles
messages: + msg341169
2019-04-30 17:02:11xtreaksetnosy: + gregory.p.smith, xtreak
messages: + msg341159
2019-04-30 16:38:56Joe.Borgcreate