Message399464
>> "In particular, the function looks for executable (or for the
>> first item in args) relative to cwd if the executable path is
>> a relative path."
>
> For POSIX, this should be stated as a "relative path without a slash in
> it" or a "relative path without a directory in it". An unqualified
> filename is a relative path that won't be resolved against `cwd`,
> unless there's a "." entry in PATH.
While I don't understand the wording proposed (that seem backwards to me?), I do think it would be important to fix this.
I just got puzzled and spent some effort writing a workaround *not to look in cwd* for a bare command name, before I got so skeptical I actually tried empirically what Python would do -- and see the behavior was sensible and `cwd` was taken into account *only if the executable had a path component in it*.
Any other behavior is annoying IMO as it means using a `cwd` *requires* one to pass in an absolute path to the executable not to risk running an unexpected executable, which basically makes support for looking up executable in the system PATH unusable if using a `cwd`.
It would also be somewhat inconsistent with the idea that `cwd` only *changes* the current directory prior to execution, as it would suggest the behavior is not the same when using `cwd=None` and `cwd=os.getcwd()`.
So I'd suggest amending the wording in some way, maybe something like
"In particular, the function looks for executable (or for the first item in args) relative to cwd if the executable has an explicit relative path."
or something like that, possibly even dropping in an example.
The problem with the current wording is that usually an unqualified name *is* a relative path, whereas here one should somehow understand that it means "if it has a path component and that path component is relative", or the more down-to-earthy "if the executable starts with './' or '../'". |
|
Date |
User |
Action |
Args |
2021-08-12 15:10:31 | ban | set | recipients:
+ ban, gregory.p.smith, paul.moore, tim.golden, ned.deily, cvrebert, asvetlov, chris.jerdonek, docs@python, python-dev, zach.ware, eryksun, steve.dower, pepalogik, wolma, damon-atkins |
2021-08-12 15:10:31 | ban | set | messageid: <1628781031.89.0.923058345482.issue15533@roundup.psfhosted.org> |
2021-08-12 15:10:31 | ban | link | issue15533 messages |
2021-08-12 15:10:31 | ban | create | |
|