Skip to content

Commit 8cc605a

Browse files
Rémi Lapeyregpshead
Rémi Lapeyre
authored andcommitted
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.
1 parent a15a7bc commit 8cc605a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Lib/subprocess.py

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

466466
if capture_output:
467-
if ('stdout' in kwargs) or ('stderr' in kwargs):
467+
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
468468
raise ValueError('stdout and stderr arguments may not be used '
469469
'with capture_output.')
470470
kwargs['stdout'] = PIPE
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)