[issue42388] subprocess.check_output(['echo', 'test'], text=True, input=None) fails

Alexey Izbyshev report at bugs.python.org
Sun Nov 22 12:12:17 EST 2020


Alexey Izbyshev <izbyshev at ispras.ru> added the comment:

It seems that allowing `input=None` to mean "redirect stdin to a pipe and send an empty string there" in `subprocess.check_output` was an accident(?), and this behavior is inconsistent with `subprocess.run` and `communicate`, where `input=None` has the same effect as not specifying it at all.

The docs for `subprocess.check_output` say:

The arguments shown above are merely some common ones. The full function signature is largely the same as that of run() - most arguments are passed directly through to that interface. However, explicitly passing input=None to inherit the parent’s standard input file handle is not supported.

They don't make it clear the effect of passing `input=None` though. I also couldn't find any tests that would check that effect.

Since we can't just forbid `input=None` for `check_output` at this point (probably can't even limit that to the case when `text` is used, since it was added in 3.7), I think that we need to extend the check pointed to by ThiefMaster to cover `text`, clarify the docs and add a test.

----------
nosy: +gregory.p.smith, izbyshev
versions: +Python 3.10, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42388>
_______________________________________


More information about the Python-bugs-list mailing list