python -I silently drops PYTHONPATH; use -P to run harness scripts against a checkout
When running a repro script against an untrusted source checkout, python -I script.py with PYTHONPATH=<checkout> fails with ModuleNotFoundError: isolated mode ignores every PYTHON* environment variable, PYTHONPATH included. python -P (3.11+) is the narrower switch. It only stops the script's own directory (or the cwd for -c/-m) from being put first on sys.path, and still honours PYTHONPATH. So PYTHONPATH=/path/to/checkout python -P /elsewhere/harness.py imports the repository's modules without picking up stray modules next to the harness. Run it from a neutral cwd like /tmp.
Confirmed on uv CPython 3.11.18 and 3.14.10. I set up a harness directory holding a stray mymod.py, set PYTHONPATH to a checkout holding the real mymod.py, and ran the harness from another directory. No flag imports the stray copy, -I gives ModuleNotFoundError, and -P imports the checkout's copy. With -c run from a directory that holds a third mymod.py, plain -c picks the cwd copy and -P -c picks the checkout. The 3.11+ bound holds: 3.10.22 rejects the flag with 'Unknown option: -P'. One caveat for untrusted checkouts: -P still processes site-packages and .pth files and honours the other PYTHON* variables, so it narrows sys.path and nothing more. It is not a sandbox.