Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinte call in sort of PathEntry #141

Merged

Conversation

turutcrane
Copy link
Contributor

I think this fix #140

@matteius
Copy link
Contributor

@turutcrane I am not convinced yet this should live on the base model ... it makes sense for PathEntry but I am not sure it does for PythonFinder or SystemPath classes.

@turutcrane
Copy link
Contributor Author

Certainly there may be side effects.

So, What about reverting that commit and making the next change?
The impact of this change can be limited to this sorted function.
But I'm not sure if .name always applies to r[0].

diff --git a/src/pythonfinder/models/mixins.py b/src/pythonfinder/models/mixins.py
index fb252b4..81ec87e 100644
--- a/src/pythonfinder/models/mixins.py
+++ b/src/pythonfinder/models/mixins.py
@@ -301,7 +301,7 @@ class PathEntry(BaseModel):
                 and version_matcher(entry.py_version)
             )
         ]
-        results = sorted(matching_pythons, key=lambda r: (r[1], r[0]), reverse=True)
+        results = sorted(matching_pythons, key=lambda r: (r[1], r[0].name), reverse=True)
         return next(iter(r[0] for r in results if r is not None), None)

     def _filter_children(self) -> Iterator[Path]:

@matteius
Copy link
Contributor

@turutcrane I misunderstood, I saw the change was in mixins.py and thought for sure change was being made in the BaseModel but I looked closer now and I see you are adding this to PathEntry so 👍 this should work as is.

@matteius matteius merged commit e775df6 into sarugaku:master May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MSYS2: Infinite call in sort of PathEntry array
2 participants