Skip to content

Commit 10b4fd9

Browse files
miss-islingtonRémi Lapeyre
andauthored
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 8cc605a) Co-authored-by: Rémi Lapeyre <[email protected]>
1 parent 6692d35 commit 10b4fd9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Lib/subprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,12 @@ def run(*popenargs,
458458
The other arguments are the same as for the Popen constructor.
459459
"""
460460
if input is not None:
461-
if 'stdin' in kwargs:
461+
if kwargs.get('stdin') is not None:
462462
raise ValueError('stdin and input arguments may not both be used.')
463463
kwargs['stdin'] = PIPE
464464

465465
if capture_output:
466-
if ('stdout' in kwargs) or ('stderr' in kwargs):
466+
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
467467
raise ValueError('stdout and stderr arguments may not be used '
468468
'with capture_output.')
469469
kwargs['stdout'] = PIPE
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fix an unintended ValueError from :func:`subprocess.run` when checking for
2+
conflicting `input` and `stdin` or `capture_output` and `stdout` or `stderr`
3+
args when they were explicitly provided but with `None` values within a
4+
passed in `**kwargs` dict rather than as passed directly by name. Patch
5+
contributed by Rémi Lapeyre.

0 commit comments

Comments
 (0)