Skip to content

fix(python): match two-digit minor versions in pyuserpaths - #14161

Merged
robbyrussell merged 1 commit into
ohmyzsh:masterfrom
shoutoutuoadi325:fix-python-pyuserpaths
Oct 8, 2026
Merged

robbyrussell merged 1 commit into
ohmyzsh:masterfrom
shoutoutuoadi325:fix-python-pyuserpaths

Conversation

@shoutoutuoadi325

Copy link
Copy Markdown
Contributor

Changes:

pyuserpaths has been silently doing nothing on python 3.10 and newer.

The version is parsed with a shortest match:

version=${(M)${"$($python -V 2>&1)":7}#[^.]##.[^.]##}

so Python 3.11.4 comes out as 3.1, Python 3.13.1 also as 3.1, and the check then looks for ~/.local/lib/python3.1/site-packages, which never exists, so the path is skipped. It only ever worked by accident, because before 3.10 the minor version was a single digit (3.9.7 -> 3.9).

Switching # to ## makes it a longest match and keeps the whole minor version:

% python3 -V
Python 3.11.4
% pyuserpaths; echo $PYTHONPATH
/home/me/.local/lib/python3.11/site-packages

Tested with python stubs reporting 2.7.18, 3.9.7, 3.10, 3.11.4 and 3.13.1: the old versions still parse the same, a missing site-packages directory is still skipped, PYTHONUSERBASE is still honored, and an existing PYTHONPATH is kept without duplicate entries.

The version pattern used the shortest match (#), so "Python 3.11.4"
was truncated to 3.1 and the ~/.local/lib/python3.11/site-packages
check never matched on python >= 3.10, leaving pyuserpaths a no-op.
Use a longest match (##) so the whole minor version is kept.
Copilot AI balanced review requested due to automatic review settings October 8, 2026 07:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ohmyzsh ohmyzsh Bot added this to Main project Oct 8, 2026

@robbyrussell robbyrussell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your first contribution to Oh My Zsh! This one has been quietly broken on every Python since 3.10, so it's a good catch. I checked the old and new parsing against a handful of versions (3.9, 3.10, 3.13, a 3.14 rc) and it does the right thing now. Merging.

@robbyrussell
robbyrussell merged commit 361fb5c into ohmyzsh:master Oct 8, 2026
1 check passed
RH203 pushed a commit to RH203/ohmyzsh that referenced this pull request Oct 28, 2026
…4161)

The version pattern used the shortest match (#), so "Python 3.11.4"
was truncated to 3.1 and the ~/.local/lib/python3.11/site-packages
check never matched on python >= 3.10, leaving pyuserpaths a no-op.
Use a longest match (##) so the whole minor version is kept.
tutkun pushed a commit to tutkun/ohmyzsh that referenced this pull request Oct 29, 2026
…4161)

The version pattern used the shortest match (#), so "Python 3.11.4"
was truncated to 3.1 and the ~/.local/lib/python3.11/site-packages
check never matched on python >= 3.10, leaving pyuserpaths a no-op.
Use a longest match (##) so the whole minor version is kept.
jizongFox pushed a commit to jizongFox/ohmyzsh that referenced this pull request Nov 2, 2026
…4161)

The version pattern used the shortest match (#), so "Python 3.11.4"
was truncated to 3.1 and the ~/.local/lib/python3.11/site-packages
check never matched on python >= 3.10, leaving pyuserpaths a no-op.
Use a longest match (##) so the whole minor version is kept.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants