decoded according to locale encoding, or by "encoding" if set. Text mode
is triggered by setting any of text, encoding, errors or universal_newlines.
"""
- if 'stdout' in kwargs:
- raise ValueError('stdout argument not allowed, it will be overridden.')
+ for kw in ('stdout', 'check'):
+ if kw in kwargs:
+ raise ValueError(f'{kw} argument not allowed, it will be overridden.')
if 'input' in kwargs and kwargs['input'] is None:
# Explicitly passing input=None was previously equivalent to passing an
[sys.executable, "-c", "print('BDFL')"])
self.assertIn(b'BDFL', output)
+ with self.assertRaisesRegex(ValueError,
+ "stdout argument not allowed, it will be overridden"):
+ subprocess.check_output([], stdout=None)
+
+ with self.assertRaisesRegex(ValueError,
+ "check argument not allowed, it will be overridden"):
+ subprocess.check_output([], check=False)
+
def test_check_output_nonzero(self):
# check_call() function with non-zero return code
with self.assertRaises(subprocess.CalledProcessError) as c:
--- /dev/null
+:meth:`subprocess.check_output` now raises :exc:`ValueError` when the
+invalid keyword argument *check* is passed by user code. Previously
+such use would fail later with a :exc:`TypeError`.
+Patch by Rémi Lapeyre.