Python session with 3.5b2
Showing existing error:
>>> from shutil import which
Works OK
>>> which("python")
'C:\\Python27\\python.EXE'
Also works OK
>>> which('C:\\Python27\\python.EXE')
'C:\\Python27\\python.EXE'
Fails
>>> which('C:\\Python27\\python')
>>>
Showing better results with my fix (attached):
>>> from which2 import which
>>> which("python")
'C:\\Python27\\python.exe'
>>> which('C:\\Python27\\python.exe')
'C:\\Python27\\python.exe'
>>> which('C:\\Python27\\python')
'C:\\Python27\\python.exe'
Problem is with the short-circuiting code near the beginning of the function. It fails to check the extensions for Windows when short-circuited.
My fix has a few other improvements -- efficiency and nicer output without those ugly upper-case extensions. |