bpo-34886: Fix subprocess.run handling of exclusive arguments (GH-11727)

Fix an unintended ValueError from :func:`subprocess.run` when checking for
conflicting `input` and `stdin` or `capture_output` and `stdout` or `stderr` args
when they were explicitly provided but with `None` values within a passed in
`**kwargs` dict rather than as passed directly by name.
(cherry picked from commit 8cc605acdd)

Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
This commit is contained in:
Miss Islington (bot) 2019-06-08 08:15:02 -07:00 committed by GitHub
parent 22b69da4c3
commit 6324ac1293
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -459,12 +459,12 @@ def run(*popenargs,
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if 'stdin' in kwargs:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if ('stdout' in kwargs) or ('stderr' in kwargs):
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE

View file

@ -0,0 +1,5 @@
Fix an unintended ValueError from :func:`subprocess.run` when checking for
conflicting `input` and `stdin` or `capture_output` and `stdout` or `stderr`
args when they were explicitly provided but with `None` values within a
passed in `**kwargs` dict rather than as passed directly by name. Patch
contributed by Rémi Lapeyre.