[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-08-28 Thread STINNER Victor


New submission from STINNER Victor :

Example:

$ env -i ./python -c 'import distutils.spawn; 
print(distutils.spawn.find_executable("true"))'
Traceback (most recent call last):
  File "", line 1, in 
  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.

--
components: Library (Lib)
messages: 324245
nosy: vstinner
priority: normal
severity: normal
status: open
title: distutils: find_executable() fails if the PATH environment variable is 
not set
versions: Python 2.7, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-08-28 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +8449
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-08-28 Thread STINNER Victor


STINNER Victor  added the comment:

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

--
nosy: +Marcus.Smith, dstufft, ncoghlan, paul.moore
versions:  -Python 2.7, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-08-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

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.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-08-30 Thread STINNER Victor


STINNER Victor  added the comment:

> find_executable() always searches executables from the current directory.

Oh! I didn't notice that!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-03 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +8511

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-03 Thread STINNER Victor


STINNER Victor  added the comment:

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.

--
versions: +Python 2.7, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-04 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8516

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-04 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 39487196c87e28128ea907a0d9b8a88ba53f68d5 by Victor Stinner in 
branch 'master':
bpo-34530: Fix distutils find_executable() (GH-9049)
https://github.com/python/cpython/commit/39487196c87e28128ea907a0d9b8a88ba53f68d5


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-04 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8517

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-04 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +8518

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-04 Thread miss-islington


miss-islington  added the comment:


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


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-04 Thread STINNER Victor


STINNER Victor  added the comment:


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


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-05 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +8531

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-05 Thread STINNER Victor


STINNER Victor  added the comment:


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


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34530] distutils: find_executable() fails if the PATH environment variable is not set

2018-09-05 Thread STINNER Victor


STINNER Victor  added the comment:

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.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com