Skip to content

test/setpython: don't allow local ./python to fool version check

Eric Sunshine requested to merge sunshineco/reposurgeon:es/setpython into master

setpython creates a local link named python pointing at the requested python version, either python2 or python3. As of 2017-03-09T14:56:50-05:00!sunshine@sunshineco.com, if it does not find a Python interpreter with either of those names, it also checks bare python to see if it is of the requested version. Unfortunately, the check for bare python can be fooled by the local link named python already created by setpython.

For instance, assume that setpython has already pointed the local python link at python3. Further assume that Python 2 is installed but only under the name python, not under the name python2. When setpython attempts to check the version of bare python, it may, depending upon the order of directories in PATH, incorrectly interrogate the local python link, which reports Python 3, rather than interrogating the real bare-named Python 2 interpreter, python.

Fix this shortcoming.

Merge request reports