You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The logic in pyinfo.py will be broken if this environment variable is set.
The best fix is probably to set the environment variable when calling pyinfo in a subprocess on Python 3.11 and newer. This happens in modulefinder.py. We can then only do the sys.path hackery in pyinfo.py on older Python versions
The text was updated successfully, but these errors were encountered:
Fixes#15110
- Add PYTHONSAFEPATH="true" to call to subprocess in get_search_dirs()
- Check sys.version_info before modifying path in pyinfo.py
To test, import mypy.modulefinder.get_search_dirs & run:
- get_search_dirs() with no args
- on Python 3.11, call get_search_dirs with an earlier version as
python_executable
- on Python < 3.11, call get_search_dirs with Python 3.11 as
python_executable
Expected:
- consistent results, no exceptions
Co-authored-by: eevel <eevel@weezel3.weezelnet>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Python 3.11 adds a PYTHONSAFEPATH environment variable /
-P
flag that prevents script directory from ending up on PYTHONPATH: https://docs.python.org/3/using/cmdline.html#cmdoption-PThe logic in pyinfo.py will be broken if this environment variable is set.
The best fix is probably to set the environment variable when calling pyinfo in a subprocess on Python 3.11 and newer. This happens in modulefinder.py. We can then only do the sys.path hackery in pyinfo.py on older Python versions
The text was updated successfully, but these errors were encountered: