subprocess-tee icon indicating copy to clipboard operation
subprocess-tee copied to clipboard

Windows: Argument list converted to string incorrectly

Open robertschweizer opened this issue 2 years ago • 0 comments

When passing a list of arguments, subprocess-tee converts that to a single string with shlex.join. If one of the arguments contains a backslash, it is enclosed in single-quotes ('). This leads to the following error on Windows:

$ python -c "from subprocess_tee import run; import sys; run([sys.executable, '-V'], executable=None)"
The filename, directory name, or volume label syntax is incorrect.

Workaround

Pass the arguments as string.

Fix

shlex.join is only meant for POSIX systems. On Windows, subprocess.list2cmdline can be used to convert argument lists to strings, but is not officially part of the Python API (https://bugs.python.org/issue10838).

robertschweizer avatar Aug 29 '23 16:08 robertschweizer