fix(venv): escape glob characters in the venv lookup prefix - #3869
Merged
frostming merged 1 commit intoAug 30, 2026
Merged
Conversation
get_venv_prefix builds the prefix from the project directory name, and venv create writes that name to disk literally. iter_venvs fed the same string to Path.glob, where [ and ] are pattern metacharacters and are legal in Windows directory names. A project in my[project] or downloads[1] produced a pattern that never matched its own venv, so venv list, venv remove, venv activate and interpreter discovery all silently saw nothing. The ident slice keeps the unescaped length because it indexes the real on-disk name, not the pattern.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3869 +/- ##
=======================================
Coverage 88.79% 88.79%
=======================================
Files 120 120
Lines 13321 13322 +1
Branches 2265 2265
=======================================
+ Hits 11828 11829 +1
Misses 931 931
Partials 562 562
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
frostming
approved these changes
Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
get_venv_prefixbuilds the prefix from the project directory name, andvenv createwrites that name to disk literally.iter_venvsthen feeds the same string toPath.glob, where[and]are pattern metacharacters and are legal in Windows directory names. A project inmy[project], or the common browser-download formdownloads[1], produces a pattern that never matches its own venv, sovenv list,venv remove,venv activate,pdm use --venvand interpreter discovery all silently see nothing. No error is raised.On the unpatched source the added test reports:
iter_venvsyields nothing while the venv it should find is on disk.glob.escaperather thaniterdir()andstartswith, becauseglobreturns empty for a missing venv parent directory whileiterdir()raisesFileNotFoundError, which is the normal state on a fresh machine. Theidentslice keeps the unescaped length, since it indexes the real on-disk name rather than the pattern.Scoped suite on Windows 11, CPython 3.13.5: 481 passed, 5 skipped.