gh-157006: Fix test_embed when PYTHONSTARTUP is set - #157007
Open
cmaloney wants to merge 1 commit into
Open
Conversation
Remove python-specific environment variables in test_embed cases. Helpers now start with a `PYTHON*` environment variable free copy of `os.environ` then add back in known runtime changing flags. This makes it so specific host configuration, such as PYTHON_GIL is kept while isolating tests from unintended changes. Individual tests which need to check specific behaviors can pass `env=` to validate embedded interpreter behavior.
cmaloney
commented
Sep 5, 2026
| # Windows requires at least the SYSTEMROOT environment variable to | ||
| # start Python. | ||
| env = env.copy() | ||
| env['SYSTEMROOT'] = os.environ['SYSTEMROOT'] |
Contributor
Author
There was a problem hiding this comment.
note: SYSTEMROOT is now always kept so this line is a no-op
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove python-specific environment variables in test_embed cases. Helpers now start with a
PYTHON*environment variable free copy ofos.environthen add back in known runtime changing flags. This makes it so specific host configuration, such as PYTHON_GIL, is kept while isolating tests from unintended changes. Individual tests which need to check specific behaviors can passenv=to validate embedded interpreter behavior.