uv
396ff569 - Fix `PYTHONHOME` inheritance when spawning different Python versions (#17821)

Commit
18 days ago
Fix `PYTHONHOME` inheritance when spawning different Python versions (#17821) ## Summary Fixes #17814. When a Python version installed by uv spawns another Python version via subprocess (e.g., Python 3.12 spawning Python 3.13), the child process would inherit the parent's `PYTHONHOME` environment variable. This caused the child Python to load the wrong stdlib, resulting in errors like `AssertionError: SRE module mismatch`. The fix removes the check that prevented overwriting an inherited `PYTHONHOME` value. Now the Windows trampoline always sets `PYTHONHOME` to the correct directory for non-virtualenv Python installations, ensuring each Python version uses its own stdlib. ## Test Plan Tested manually using the reproduction script from the issue: ``` uv python install 3.12 uv python install 3.13 echo "from os import environ;print(environ['PYTHONHOME']);import re" > test.py python3.12.exe -c "import subprocess; subprocess.run(['python3.13.exe', 'test.py'])" ``` Before: `AssertionError: SRE module mismatch` After: Runs successfully with correct `PYTHONHOME` pointing to 3.13's installation. --------- Co-authored-by: Zanie Blue <contact@zanie.dev>
Author
Parents
Loading