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 <>
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.


    if executable is not None and not isinstance(executable, str):
        executable = os.fsdecode(executable)

    if not isinstance(args, str):
            args = list2cmdline(args)
        except TypeError:
            if isinstance(args, bytes):
                args = os.fsdecode(args)
            elif isinstance(args, os.PathLike):
                args = list2cmdline([args])
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:


    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:27eryksunsetrecipients: + eryksun, gregory.p.smith, ned.deily, r.david.murray, njs, serhiy.storchaka, Phaqui, Roy Williams
2018-02-07 08:21:27eryksunsetmessageid: <>
2018-02-07 08:21:27eryksunlinkissue31961 messages
2018-02-07 08:21:27eryksuncreate