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

15110: set env var for subprocess, check version in script #15122

Merged
merged 5 commits into from
Apr 25, 2023

Conversation

eevelweezel
Copy link
Contributor

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

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks for the fix!

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator

Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python quite bizarre. The internet suggests that doing the equivalent of passing env={**os.environ, "PYTHONSAFEPATH": "1"} will work

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

mypy/modulefinder.py Outdated Show resolved Hide resolved
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JukkaL JukkaL merged commit 0dafc47 into python:master Apr 25, 2023
@hauntsaninja
Copy link
Collaborator

Thanks again!

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.

Fix pyinfo.py if PYTHONSAFEPATH is set
4 participants