fix(python): tolerate older virtualenv PythonSpec missing machine/free_threaded#3935
Open
SAY-5 wants to merge 2 commits intotox-dev:mainfrom
Open
fix(python): tolerate older virtualenv PythonSpec missing machine/free_threaded#3935SAY-5 wants to merge 2 commits intotox-dev:mainfrom
SAY-5 wants to merge 2 commits intotox-dev:mainfrom
Conversation
…e_threaded Signed-off-by: SAY-5 <saiasish.cnp@gmail.com>
for more information, see https://pre-commit.ci
gaborbernat
requested changes
May 11, 2026
Member
gaborbernat
left a comment
There was a problem hiding this comment.
Wouldn't this imply that on those environments we would not satisfy potentially the requirement? I would rather fail loud, like we do now, than silently do the wrong thing. People should upgrade their virtual lamp, and we should specifically require that, rather than this kind of fall back to bad behavior.
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.
tox -e fix)docs/changelogfolderFixes #3934.
_validate_base_pythoniterates over("implementation", "major", "minor", "micro", "architecture", "machine", "free_threaded")and unconditionally callsgetattr(spec_name, key)on thePythonSpecreturned byvirtualenv. Themachineandfree_threadedattributes were introduced in newervirtualenvreleases, so on systems that still ship an oldervirtualenv(e.g. OpenIndiana's system package,virtualenv 20.37.0),tox -e py314aborts with:Switching the lookups to
getattr(spec, key, None)makes the comparison safely treat the missing keys as "no constraint", restoring the pre-3815 behaviour for environments that have not upgradedvirtualenvyet. Added a regression test that monkey-patchesPythonSpec.from_string_specto return an attribute-stripped spec.