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

MSYS2: Infinite call in sort of PathEntry array #140

Closed
turutcrane opened this issue May 30, 2023 · 0 comments · Fixed by #141
Closed

MSYS2: Infinite call in sort of PathEntry array #140

turutcrane opened this issue May 30, 2023 · 0 comments · Fixed by #141

Comments

@turutcrane
Copy link
Contributor

My original issue is pypa/pipenv#5709.
It caused in vendered pythonfinder in phpenv. So, I add this issue.

Problem: The following code causes RecursionError: maximum recursion depth exceeded in my MSYS environment on Windows.

from pythonfinder import Finder
f = Finder()
# p = f.find_all_python_versions()
p = f.find_python_version(3)
print("My python:", p)

I expect a result.

My python: D:/DiskD/develop/msys64/mingw64/bin/python3.exe

Error output is here

Traceback (most recent call last):
  File "D:\DiskD\develop\turutcrane\pythonfinder\src\test.py", line 7, in <module>
    p = f.find_python_version(3)
  File "D:/DiskD\develop\turutcrane\pythonfinder\src/pythonfinder/pythonfinder.py", line 174, in find_python_version
    return self.system_path.find_python_version(
  File "D:/DiskD\develop\turutcrane\pythonfinder\src/pythonfinder/models/path.py", line 471, in find_python_version
    ver = next(iter(self.get_pythons(sub_finder)), None)
  File "D:/DiskD\develop\turutcrane\pythonfinder\src/pythonfinder/models/path.py", line 405, in get_pythons
    pythons = [entry for entry in self._get_all_pythons(finder)]
  File "D:/DiskD\develop\turutcrane\pythonfinder\src/pythonfinder/models/path.py", line 405, in <listcomp>
    pythons = [entry for entry in self._get_all_pythons(finder)]
  File "D:/DiskD\develop\turutcrane\pythonfinder\src/pythonfinder/models/path.py", line 397, in _get_all_pythons
    for python in self._filter_paths(finder):
  File "D:/DiskD\develop\turutcrane\pythonfinder\src/pythonfinder/models/path.py", line 390, in _filter_paths
    python_versions = finder(path)
  File "D:/DiskD\develop\turutcrane\pythonfinder\src/pythonfinder/models/path.py", line 449, in sub_finder
    return obj.find_python_version(major, minor, patch, pre, dev, arch, name)
  File "D:/DiskD\develop\turutcrane\pythonfinder\src/pythonfinder/models/mixins.py", line 304, in find_python_version
    results = sorted(matching_pythons, key=lambda r: (r[1], r[0]), reverse=True)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 909, in __eq__
    return self.dict() == other.dict()
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 449, in dict
    return dict(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 868, in _iter
    v = self._get_value(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 761, in _get_value
    return {
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 762, in <dictcomp>
    k_: cls._get_value(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 743, in _get_value
    v_dict = v.dict(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 449, in dict
    return dict(

   ... loop ...

  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 743, in _get_value
    v_dict = v.dict(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 449, in dict
    return dict(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 868, in _iter
    v = self._get_value(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 761, in _get_value
    return {
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 762, in <dictcomp>
    k_: cls._get_value(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 741, in _get_value
    if isinstance(v, BaseModel):
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pydantic/main.py", line 304, in __instancecheck__
    return hasattr(instance, '__fields__') and super().__instancecheck__(instance)
  File "D:/DiskD/develop/msys64/mingw64/lib/python3.10/abc.py", line 119, in __instancecheck__
    return _abc_instancecheck(cls, instance)
RecursionError: maximum recursion depth exceeded in comparison
src/pythonfinder/models/mixins.py", line 304, in find_python_version
    results = sorted(matching_pythons, key=lambda r: (r[1], r[0]), reverse=True)

calls eq in /pydantic/main.py, then start infinite call.

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 a pull request may close this issue.

1 participant