This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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.
History
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: <1517991687.8.0.467229070634.issue31961@psf.upfronthosting.co.za>
2018-02-07 08:21:27eryksunlinkissue31961 messages
2018-02-07 08:21:27eryksuncreate