Original file line numberDiff line numberDiff line change@@ -839,6 +839,9 @@ def __init__(self, args, bufsize=-1, executable=None,
839839ifnotisinstance(bufsize, int):
840840raiseTypeError("bufsize must be an integer")
841841842+ifstdoutisSTDOUT:
843+raiseValueError("STDOUT can only be used for stderr")
844+842845ifpipesizeisNone:
843846pipesize=-1# Restore default
844847ifnotisinstance(pipesize, int):
Original file line numberDiff line numberDiff line change@@ -1763,6 +1763,13 @@ def test_capture_output(self):
17631763self.assertIn(b'BDFL', cp.stdout)
17641764self.assertIn(b'FLUFL', cp.stderr)
176517651766+deftest_stdout_stdout(self):
1767+# run() refuses to accept stdout=STDOUT
1768+withself.assertRaises(ValueError,
1769+msg=("STDOUT can only be used for stderr")):
1770+self.run_python("print('will not be run')",
1771+stdout=subprocess.STDOUT)
1772+17661773deftest_stdout_with_capture_output_arg(self):
17671774# run() refuses to accept 'stdout' with 'capture_output'
17681775tf=tempfile.TemporaryFile()
Original file line numberDiff line numberDiff line change@@ -0,0 +1,2 @@
1+In :mod:`subprocess`, raise a more informative message when
2+``stdout=STDOUT``.