-
-
Notifications
You must be signed in to change notification settings - Fork 441
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
Support PYTHONSAFEPATH #1700
Support PYTHONSAFEPATH #1700
Conversation
Thanks! I'll have to look into what you are saying about the check in execfile. That code gets very fiddly. |
All done! |
Hmm, this is hard to test. The test might work better in |
I've proposed some test fixes here: flying-sheep#1 |
OK, I’ll take a look tomorrow! |
OK, looks good. Seems like on windows, there‘s an additional line "d:\\a\\coveragepy\\coveragepy\\.tox\\py311\\scripts\\coverage.exe", in the PYTHONPATH. I don’t know why, and I don’t have access to windows to figure it out. |
I've started looking into the failing Windows builds in hopes of getting this PR unblocked. I'm currently suspicious of the PYTHONSAFEPATH behavior of CPython itself on Windows. This diff in particular seems sus. At first glance it looks like it should be a no-op, since the function referenced in the comment was already not used within that file. It's odd to see what appears to be a cleanup diff included in an otherwise very focused commit, though, and I wonder whether it was unintentional and/or had unintended side effects. It may have also been a follow-up to changes from a previous commit, but I haven't found any candidates yet. The referenced This might be a red herring, but I have to go now, so figured I'd go ahead and share it in case I'm not able to return to the case for a while. |
Additional data points, which seem more relevant:
I feel like there's probably enough info there to figure out what's happening, but I'm having trouble putting the pieces together and have to go again. Let me know if anyone else has a lightbulb moment, and I'll follow up with some more detailed debug dumps later. |
Maybe we can ask a core dev about this? |
Hi, as said, I don’t have access to windows. Can you suggest a course of action that gets this merged? Like “just remove that entry during test execution and add a TODO with a link to an issue we open for it” |
Hello? |
Can we please get someone to help with this? It's basically the one reason people could still prefer |
I'm trying to look into this some more, and boil it down to a question a core team member can help answer.
This surprises me: you're the only person who has asked about PYTHONSAFEPATH, and most people (inexplicably) like pytest --cov because it lets them pile everything into one command with crazy command-line options. Can you tell me some more about how you are using PYTHONSAFEPATH? There are a few ways to enable it (environment variable, Also, just for my fuller understanding: why use PYTHONSAFEPATH? |
It’s a good suggestion because it’s quite common to have an importable module (e.g. a TBH, |
I did some experimenting (https://github.com/nedbat/safe-path-tests) and wrote a CPython issue: python/cpython#131484 |
Thank you! |
I've finished this work in commit 32e8d79. I gave up on making Windows work exactly right for the |
Fixes #1696
Unfortunately, the test I added doesn’t really do much, since the code always hits this branch while testing.
coveragepy/coverage/execfile.py
Lines 106 to 117 in 8086c70
I manually confirmed that my change works, but allowing to actually test
PyRunner.prepare
, more extensive changes to the test setup are necessary that I don’t feel comfortable making.Once a change is made that skips that branch during testing, my test will start working and catch breakage to the PYTHONSAFEPATH handling.