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 docs@python, eryksun, gps, gregory.p.smith, jaystrict, r.david.murray
Date 2021-03-12.03:56:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615521366.83.0.871201539729.issue25481@roundup.psfhosted.org>
In-reply-to
Content
> So, two interesting questions: does this in fact match the behavior of 
> os._execvpe, and does it match the behavior of the shell? 

I think it's fine. child_exec() tries all paths. It saves the first error that's not ENOENT or ENOTDIR. The saved error gets reported back, else ENOENT or ENOTDIR. This is the same as os._execvpe:

    for dir in path_list:
        fullname = path.join(dir, file)
        try:
            exec_func(fullname, *argrest)
        except (FileNotFoundError, NotADirectoryError) as e:
            last_exc = e
        except OSError as e:
            last_exc = e
            if saved_exc is None:
                saved_exc = e
    if saved_exc is not None:
        raise saved_exc
    raise last_exc

Perhaps the rule for PATH search errors should be documented for os.execvp[e] and subprocess.

I think it matches the shell, except, AFAIK, the shell doesn't distinguish ENOENT and ENOTDIR errors. For example, where "/noexec" is a directory that has no execute access:

    $ /bin/sh -c spam
    /bin/sh: 1: spam: not found

    $ PATH=/noexec:$PATH /bin/sh -c spam
    /bin/sh: 1: spam: Permission denied
History
Date User Action Args
2021-03-12 03:56:06eryksunsetrecipients: + eryksun, gregory.p.smith, gps, r.david.murray, docs@python, jaystrict
2021-03-12 03:56:06eryksunsetmessageid: <1615521366.83.0.871201539729.issue25481@roundup.psfhosted.org>
2021-03-12 03:56:06eryksunlinkissue25481 messages
2021-03-12 03:56:06eryksuncreate