py3versions doesn't follow symlinks (like realpath)

Bug #2015243 reported by Kostiantyn Astakhov
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python3-defaults (Ubuntu)
New
Undecided
Unassigned

Bug Description

In case if we have more than one python version and manage them by update-alternatives, the path to the python binary looks like:
root@devvm-14-143:~# ls -la /usr/bin/python3
lrwxrwxrwx 1 root root 25 Apr 4 08:11 /usr/bin/python3 -> /etc/alternatives/python3
root@devvm-14-143:~# ls -la /etc/alternatives/python3
lrwxrwxrwx 1 root root 18 Apr 4 08:11 /etc/alternatives/python3 -> /usr/bin/python3.8

So even we use the correct default version of python3 (like in Focal it is python3.8) py3version will fail

root@devvm-14-143:~# py3versions -d
py3versions: the symlink /usr/bin/python3 does not point to the python3 default version. It must be reset to point to python3.8

This caused due to os.readlink doesn't follow multiply symlinks, so I suggest to use Path from pathlib.

I have attached patch with suggested changes.

Tags: patch
Revision history for this message
Kostiantyn Astakhov (glaubway) wrote :
summary: - py3versions desn't follow symlinks (like realpath)
+ py3versions doesn't follow symlinks (like realpath)
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "py3versions.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
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.