pyversions fails after update-alternatives

Bug #691762 reported by Kynn Jones
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-central (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: python-central

Bug found in package python-central:

% apt-cache policy python-central
python-central:
  Installed: 0.6.15ubuntu2
  Candidate: 0.6.15ubuntu2
  Version table:
 *** 0.6.15ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ maverick/main amd64 Packages
        100 /var/lib/dpkg/status

% lsb_release -rd
Description: Ubuntu 10.10
Release: 10.10

If one uses the standard Debian facility update-alternatives to set up alternatives for python, then calls to pyversions (or to any pycentral function that uses pyversions) will fail. E.g.:

% sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.6 20
...
% sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10
...
% which python
/usr/bin/python
% readlink -e $(which python)
/usr/bin/python2.6
% pyversions -vd
pyversions: /usr/bin/python does not match the python default version. It must be reset to point to python2.6

The reason is that pyversion uses os.readlink to determine the actual executable that /usr/bin/python points to,
but readlink only follows one symlink, which means that it will not return the desired value if the first symlink
points to another symlink, as is the case after running update-alternatives as shown above:

% readlink $(which python)
/etc/alternatives/python
% readlink $(readlink $(which python))
/usr/bin/python2.6

The solution is simple: just change the call to os.readlink in pyversions to os.path.realpath.

This bug was present in both /usr/share/pycentral-data/pyversions.py and in /usr/bin/pyversions.

Revision history for this message
Matthias Klose (doko) wrote :

you are not supposed to change the python symlink. hardly anything is ready for python2.7 in maverick

Changed in python-central (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.