[New-bugs-announce] [issue33319] `subprocess.run` documentation doesn't tell is using `stdout=PIPE` safe

Pekka Klärck report at bugs.python.org
Fri Apr 20 09:05:14 EDT 2018

New submission from Pekka Klärck <pekka.klarck at gmail.com>:

I'm porting old scripts from Python 2.7 to 3.6 and plan to change `subprocess.call()` to `subprocess.run()` at the same time. When using `call()` I've used `tempfile.TemporaryFile` as stdout because it's documentation has this warning:

    Note: Do not use stdout=PIPE or stderr=PIPE with this function. The child process will block if it generates enough output to a pipe to fill up the OS pipe buffer as the pipes are not being read from.

Interestingly there is no such note in the docs of `run()`, and based on my (possibly inadequate) testing I couldn't get it to hang either. I'm still somewhat worried about using `stdout=PIPE` with it because the docs don't explicitly say it would be safe. I'm especially worried because the docs of `call()` nowadays say that it's equivalent to `run(...).returncode`. If that's the case, then I would expect the warning in `call()` to apply also to `run()`. Or is the warning nowadays outdated altogether?

messages: 315510
nosy: pekka.klarck
priority: normal
severity: normal
status: open
title: `subprocess.run` documentation doesn't tell is using `stdout=PIPE` safe

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list