GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||
GeezerVison is showing github.com — gh-118234: Document Python subprocess requirement on `SystemRoot` env, add RuntimeWarning by jhohm · Pull Request #134435 · python/cpython Conversation
|
|
Apparently some regression tests trigger this: https://github.com/python/cpython/actions/runs/15171090613/job/42661034135 Even though Does the Windows CI runner not set SystemRoot? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
You can check "Display build info" which says: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I'd be suspicious of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| if env is not None and not any( | ||
| k.upper() == 'SYSTEMROOT' and v for k, v in env.items()): | ||
| warnings.warn("env lacks a valid 'SystemRoot'.", RuntimeWarning) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I dislike this RuntimeWarning. It's ok to run programs without SystemRoot env var, or even in an empty environment. It just works fine currently for some programs. Example:
import subprocess, sys cmd = [sys.executable, '-c', 'print("Hello World")'] subprocess.run(cmd, env={})
This program just works, it displays "Hello World" as expected.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to synthesize this feedback with #134363 (comment).
How do we prevent the problem, if not warning about it, and not setting it in the subprocess? Should we implicitly override the caller's choices and clone SystemRoot into the subprocess env?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we have to prevent the problem. We can document it and explain how to avoid it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Well, it works since Windows decided that using PATH to locate runtime dependencies (like an LD_LIBRARY_PATH equivalent) was such a terrible idea that it bypasses it for most OS stuff, but that "fix" upsets people as well.
I'm not particularly strong either way on this fix. It bites people all the time, and it's practically always a pointless thing to do (pass an insufficient environment). At the same time, there are 5-6 other variables that also ought to be included or things will break weirdly (e.g. TEMP), and this change doesn't check for those. But I don't think we have any good way to only warn when things break.
Is there a silent-by-default-enabled-with-X-dev warning that could be used instead? Would that be okay, @vstinner?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If we add a warning, it may be better to emit the warning in the socket module, no?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is there a silent-by-default-enabled-with-X-dev warning that could be used instead? Would that be okay, @vstinner?
A warning only emitted in the Python Developer Mode (-X dev) sounds more acceptable to me, yes.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
it may be better to emit the warning in the socket module, no?
The user's system could be configured to avoid that error, even without the environment variable, while plenty of other parts could also break if they are reconfigured.
Launching an application with an empty environment is the bad idea, so that's where the warning should be. I've diagnosed that as the root cause of a lot of issues.
Do we have an existing warning? Or do we need to invent a new one? This isn't a deprecation, and that's the only warning I'm aware of.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
sockets and asyncio on Windows depend on SYSTEMROOT env var
There was an error while loading. Please reload this page.