Message311775
| Author |
eryksun |
| Recipients |
Phaqui, Roy Williams, eryksun, gregory.p.smith, ned.deily, njs, r.david.murray, serhiy.storchaka |
| Date |
2018年02月07日.08:21:27 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1517991687.8.0.467229070634.issue31961@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|