Compare commits
2 Commits
f7dca9b9c8
...
7acfe41257
Author | SHA1 | Date |
---|---|---|
Miss Islington (bot) | 7acfe41257 | |
Miss Islington (bot) | 5a6b5d8c39 |
|
@ -1163,8 +1163,9 @@ calls these functions.
|
||||||
The arguments shown above are merely some common ones.
|
The arguments shown above are merely some common ones.
|
||||||
The full function signature is largely the same as that of :func:`run` -
|
The full function signature is largely the same as that of :func:`run` -
|
||||||
most arguments are passed directly through to that interface.
|
most arguments are passed directly through to that interface.
|
||||||
However, explicitly passing ``input=None`` to inherit the parent's
|
One API deviation from :func:`run` behavior exists: passing ``input=None``
|
||||||
standard input file handle is not supported.
|
will behave the same as ``input=b''`` (or ``input=''``, depending on other
|
||||||
|
arguments) rather than using the parent's standard input file handle.
|
||||||
|
|
||||||
By default, this function will return the data as encoded bytes. The actual
|
By default, this function will return the data as encoded bytes. The actual
|
||||||
encoding of the output data may depend on the command being invoked, so the
|
encoding of the output data may depend on the command being invoked, so the
|
||||||
|
|
|
@ -415,7 +415,11 @@ def check_output(*popenargs, timeout=None, **kwargs):
|
||||||
if 'input' in kwargs and kwargs['input'] is None:
|
if 'input' in kwargs and kwargs['input'] is None:
|
||||||
# Explicitly passing input=None was previously equivalent to passing an
|
# Explicitly passing input=None was previously equivalent to passing an
|
||||||
# empty string. That is maintained here for backwards compatibility.
|
# empty string. That is maintained here for backwards compatibility.
|
||||||
kwargs['input'] = '' if kwargs.get('universal_newlines', False) else b''
|
if kwargs.get('universal_newlines') or kwargs.get('text'):
|
||||||
|
empty = ''
|
||||||
|
else:
|
||||||
|
empty = b''
|
||||||
|
kwargs['input'] = empty
|
||||||
|
|
||||||
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
|
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
|
||||||
**kwargs).stdout
|
**kwargs).stdout
|
||||||
|
|
|
@ -196,6 +196,28 @@ class ProcessTestCase(BaseTestCase):
|
||||||
input=b'pear')
|
input=b'pear')
|
||||||
self.assertIn(b'PEAR', output)
|
self.assertIn(b'PEAR', output)
|
||||||
|
|
||||||
|
def test_check_output_input_none(self):
|
||||||
|
"""input=None has a legacy meaning of input='' on check_output."""
|
||||||
|
output = subprocess.check_output(
|
||||||
|
[sys.executable, "-c",
|
||||||
|
"import sys; print('XX' if sys.stdin.read() else '')"],
|
||||||
|
input=None)
|
||||||
|
self.assertNotIn(b'XX', output)
|
||||||
|
|
||||||
|
def test_check_output_input_none_text(self):
|
||||||
|
output = subprocess.check_output(
|
||||||
|
[sys.executable, "-c",
|
||||||
|
"import sys; print('XX' if sys.stdin.read() else '')"],
|
||||||
|
input=None, text=True)
|
||||||
|
self.assertNotIn('XX', output)
|
||||||
|
|
||||||
|
def test_check_output_input_none_universal_newlines(self):
|
||||||
|
output = subprocess.check_output(
|
||||||
|
[sys.executable, "-c",
|
||||||
|
"import sys; print('XX' if sys.stdin.read() else '')"],
|
||||||
|
input=None, universal_newlines=True)
|
||||||
|
self.assertNotIn('XX', output)
|
||||||
|
|
||||||
def test_check_output_stdout_arg(self):
|
def test_check_output_stdout_arg(self):
|
||||||
# check_output() refuses to accept 'stdout' argument
|
# check_output() refuses to accept 'stdout' argument
|
||||||
with self.assertRaises(ValueError) as c:
|
with self.assertRaises(ValueError) as c:
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix subprocess.check_output(..., input=None) behavior when text=True to be
|
||||||
|
consistent with that of the documentation and universal_newlines=True.
|
|
@ -1,2 +1,2 @@
|
||||||
`EnumMeta.__prepare__` now accepts `**kwds` to properly support
|
``EnumMeta.__prepare__`` now accepts ``**kwds`` to properly support
|
||||||
`__init_subclass__`
|
``__init_subclass__``
|
||||||
|
|
Loading…
Reference in New Issue