fix system.run not using text arg

This commit is contained in:
Nick Sweeting 2024-09-25 00:41:55 -07:00
parent 5b6cf68d98
commit a2a586e369
No known key found for this signature in database

View file

@ -22,6 +22,8 @@ def run(cmd, *args, input=None, capture_output=True, timeout=None, check=False,
Mostly copied from https://github.com/python/cpython/blob/master/Lib/subprocess.py Mostly copied from https://github.com/python/cpython/blob/master/Lib/subprocess.py
""" """
cmd = [str(arg) for arg in cmd]
if input is not None: if input is not None:
if kwargs.get('stdin') is not None: if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.') raise ValueError('stdin and input arguments may not both be used.')
@ -38,7 +40,7 @@ def run(cmd, *args, input=None, capture_output=True, timeout=None, check=False,
if isinstance(cmd, (list, tuple)) and cmd[0].endswith('.py'): if isinstance(cmd, (list, tuple)) and cmd[0].endswith('.py'):
cmd = (PYTHON_BINARY, *cmd) cmd = (PYTHON_BINARY, *cmd)
with Popen(cmd, *args, start_new_session=start_new_session, **kwargs) as process: with Popen(cmd, *args, start_new_session=start_new_session, text=text, **kwargs) as process:
pgid = os.getpgid(process.pid) pgid = os.getpgid(process.pid)
try: try:
stdout, stderr = process.communicate(input, timeout=timeout) stdout, stderr = process.communicate(input, timeout=timeout)