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
We tried to support PYTHONSAFEPATH in coverage.py (pull request), and had a problem where Windows didn't behave the same as MacOS or Linux. I decided to make a small test repo for checking how it behaved natively in Python, and I think I've found a discrepancy.
The code prints a number of values from the sys module. Tox and GitHub Actions are used to run the code in a number of different ways on all three operating systems. Below are excerpts from the action runs, with links to the appropriate spots in the full runs.
When installing the code as an executable script entrypoint and run normally, the first entry in sys.path indicates the source of the code:
Bug report
Bug description:
We tried to support PYTHONSAFEPATH in coverage.py (pull request), and had a problem where Windows didn't behave the same as MacOS or Linux. I decided to make a small test repo for checking how it behaved natively in Python, and I think I've found a discrepancy.
The test repo is here: https://github.com/nedbat/safe-path-tests
The code prints a number of values from the sys module. Tox and GitHub Actions are used to run the code in a number of different ways on all three operating systems. Below are excerpts from the action runs, with links to the appropriate spots in the full runs.
When installing the code as an executable script entrypoint and run normally, the first entry in sys.path indicates the source of the code:
Windows (full action run):
MacOS (full action run):
But when run with PYTHONSAFEPATH=1, Windows still has the same first entry in sys.path while MacOS is missing it. I would expect it to be missing:
Windows (full action run):
MacOS (full action run):
The pattern continues in Python 3.12 and 3.13 as well. Linux behaves as MacOS does.
Is this correct behavior? Why does Windows keep the first sys.path entry when MacOS and Linux do not?
BTW: #123121 sounds similar, but I don't know if it's related.
Let me know if any of this is unclear, I'll try to explain. The test repo gets a bit intricate.
CPython versions tested on:
3.11, 3.12, 3.13
Operating systems tested on:
Linux, macOS, Windows
The text was updated successfully, but these errors were encountered: