shlex.join is only available in 3.8+, so only use when present

Fallback is former behaviour of joining with a space.
This commit is contained in:
Paul O'Leary McCann 2022-09-02 14:06:13 +09:00
parent 21a4182b41
commit 5cfd601697

View File

@ -974,7 +974,11 @@ def run_command(
cmd_list = command cmd_list = command
# As above, this will usually but not always be correct on Windows, but # As above, this will usually but not always be correct on Windows, but
# is only used for debugging purposes. # is only used for debugging purposes.
cmd_str = shlex.join(command) if hasattr(shlex, "join"):
cmd_str = shlex.join(command)
else:
# shlex.join is more correct, but is only available in 3.8+
cmd_str = " ".join(command)
try: try:
cmd_to_run = command if is_windows else cmd_list cmd_to_run = command if is_windows else cmd_list
ret = subprocess.run( ret = subprocess.run(