Issue34530
Created on 2018-08-28 12:47 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 8968 | closed | vstinner, 2018-08-28 12:51 | |
| PR 9049 | merged | vstinner, 2018-09-03 21:26 | |
| PR 9056 | merged | miss-islington, 2018-09-04 09:01 | |
| PR 9057 | merged | miss-islington, 2018-09-04 09:01 | |
| PR 9058 | merged | vstinner, 2018-09-04 09:18 | |
| PR 9071 | closed | vstinner, 2018-09-05 14:44 | |
| Messages (10) | |||
|---|---|---|---|
| msg324245 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-08-28 12:47 | |
Example:
$ env -i ./python -c 'import distutils.spawn; print(distutils.spawn.find_executable("true"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/vstinner/prog/python/master/Lib/distutils/spawn.py", line 176, in find_executable
path = os.environ['PATH']
File "/home/vstinner/prog/python/master/Lib/os.py", line 672, in __getitem__
raise KeyError(key) from None
KeyError: 'PATH'
Attached PR fixes the issue for the master branch.
|
|||
| msg324246 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-08-28 12:52 | |
I'm not sure that it's worth it to modify Python 3.7 and older. distutils changes are now well welcomed (breaking setuptools or pip is unpopular :-)). |
|||
| msg324380 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2018-08-30 12:32 | |
find_executable() always searches executables from the current directory. This effectively equivalent having os.curdir at the start of path. shutil.which() does this only on Windows. This change LGTM, but it potentially can break user code, thus it may be not safe to make it in maintained versions. |
|||
| msg324381 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-08-30 13:15 | |
> find_executable() always searches executables from the current directory. Oh! I didn't notice that! |
|||
| msg324539 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-09-03 21:28 | |
I missed the fact that find_executable() always lookup in the current directory, whereas shutil.which() doesn't. I abandoned my PR 8968 in favor of PR 9049 which only fix the case where PATH env var is not defined. This PR can easily be backported to all branches, whereas backporting PR 8968 to stable branches would be risky: changes to distutils are likely to break a random package on PyPI. |
|||
| msg324566 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-09-04 09:01 | |
New changeset 39487196c87e28128ea907a0d9b8a88ba53f68d5 by Victor Stinner in branch 'master': bpo-34530: Fix distutils find_executable() (GH-9049) https://github.com/python/cpython/commit/39487196c87e28128ea907a0d9b8a88ba53f68d5 |
|||
| msg324575 - (view) | Author: miss-islington (miss-islington) | Date: 2018-09-04 09:19 | |
New changeset 7aa3eadca2a50ce651ce603d6100b05bb7106f1c by Miss Islington (bot) in branch '3.7': bpo-34530: Fix distutils find_executable() (GH-9049) https://github.com/python/cpython/commit/7aa3eadca2a50ce651ce603d6100b05bb7106f1c |
|||
| msg324578 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-09-04 09:40 | |
New changeset 7056ca880bf4ff428dfb2c4eee67919dc43ecd34 by Victor Stinner in branch '2.7': bpo-34530: Fix distutils find_executable() (GH-9049) (GH-9058) https://github.com/python/cpython/commit/7056ca880bf4ff428dfb2c4eee67919dc43ecd34 |
|||
| msg324636 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-09-05 14:45 | |
New changeset e2c1657dff86decf1e232b66e766d2e51381109c by Victor Stinner (Miss Islington (bot)) in branch '3.6': bpo-34530: Fix distutils find_executable() (GH-9049) (GH-9057) https://github.com/python/cpython/commit/e2c1657dff86decf1e232b66e766d2e51381109c |
|||
| msg324640 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-09-05 14:48 | |
I chose to merge the simplest change:
- path = os.environ['PATH']
+ path = os.environ.get('PATH', os.defpath)
And I added unit tests for find_executable(). The bug is now fixed.
I'm not longer interested to reuse shutil.which() in distutils.find_executable(), since find_executable() first checks if the executable is in the current directory.
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:05 | admin | set | github: 78711 |
| 2018-09-05 14:48:46 | vstinner | set | status: open -> closed resolution: fixed messages: + msg324640 stage: patch review -> resolved |
| 2018-09-05 14:45:11 | vstinner | set | messages: + msg324636 |
| 2018-09-05 14:44:48 | vstinner | set | pull_requests: + pull_request8531 |
| 2018-09-04 09:40:35 | vstinner | set | messages: + msg324578 |
| 2018-09-04 09:19:20 | miss-islington | set | nosy:
+ miss-islington messages: + msg324575 |
| 2018-09-04 09:18:07 | vstinner | set | pull_requests: + pull_request8518 |
| 2018-09-04 09:01:30 | miss-islington | set | pull_requests: + pull_request8517 |
| 2018-09-04 09:01:21 | miss-islington | set | pull_requests: + pull_request8516 |
| 2018-09-04 09:01:13 | vstinner | set | messages: + msg324566 |
| 2018-09-03 21:28:47 | vstinner | set | messages:
+ msg324539 versions: + Python 2.7, Python 3.6, Python 3.7 |
| 2018-09-03 21:26:37 | vstinner | set | pull_requests: + pull_request8511 |
| 2018-08-30 13:15:19 | vstinner | set | messages: + msg324381 |
| 2018-08-30 12:32:37 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg324380 |
| 2018-08-28 12:52:57 | vstinner | set | nosy:
+ paul.moore, ncoghlan, dstufft, Marcus.Smith messages:
+ msg324246 |
| 2018-08-28 12:51:53 | vstinner | set | keywords:
+ patch stage: patch review pull_requests: + pull_request8449 |
| 2018-08-28 12:47:31 | vstinner | create | |