Actually, using subprocess.STDOUT does exactly what is stated in the documentation: it redirects stderr to stdout so that e.g.
command = ["/bin/ls", "/tmp", "/notthere"] process = subprocess.Popen(command, shell=False, bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = "" while (True): # Read line from stdout, break if EOF reached, append line to output line = process.stdout.readline() line = line.decode() if (line == ""): break output += line
results in variable output containing the process' output from both stdout and stderr.
stderr=subprocess.STDOUT redirects all stderr output directly to stdout of the calling process, which is a major difference.
EDIT: Updated code for newer Python versions:
command = ["/bin/ls", "/tmp", "/notthere"] process = subprocess.Popen(command, shell=False, text=True, bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = "" while (True): # Read line from stdout, break if EOF reached, append line to output line = process.stdout.readline() if (line == ""): break output += line