Message311775
If a PathLike args value is supported in Windows, then it must be processed through list2cmdline, in case it needs to be quoted. Also, the preferred usage is to pass args as a list when shell is false. This common case shouldn't be penalized as a TypeError. Also, passing `executable` as PathLike should be supported, as is already the case in the POSIX implementation. For example.
_execute_child:
if executable is not None and not isinstance(executable, str):
executable = os.fsdecode(executable)
if not isinstance(args, str):
try:
args = list2cmdline(args)
except TypeError:
if isinstance(args, bytes):
args = os.fsdecode(args)
elif isinstance(args, os.PathLike):
args = list2cmdline([args])
else:
raise
list2cmdline should support PathLike arguments via os.fsdecode. This removes an existing inconsistency since the POSIX implementation converts args via PyUnicode_FSConverter in Modules/_posixsubprocess.c. For example:
list2cmdline:
for arg in seq:
if not isinstance(arg, str):
arg = os.fsdecode(arg)
Finally, passing args as a string when shell is false can never be deprecated on Windows. list2cmdline works in most cases, but Windows CreateProcess takes a command line, and applications are free to parse the command line however they want. IMHO, the case that should be deprecated is passing args as a list/sequence when shell is true. |
|
Date |
User |
Action |
Args |
2018-02-07 08:21:27 | eryksun | set | recipients:
+ eryksun, gregory.p.smith, ned.deily, r.david.murray, njs, serhiy.storchaka, Phaqui, Roy Williams |
2018-02-07 08:21:27 | eryksun | set | messageid: <1517991687.8.0.467229070634.issue31961@psf.upfronthosting.co.za> |
2018-02-07 08:21:27 | eryksun | link | issue31961 messages |
2018-02-07 08:21:27 | eryksun | create | |
|