Skip to content

gh-157006: Fix test_embed when PYTHONSTARTUP is set - #157007

Open
cmaloney wants to merge 1 commit into
python:mainfrom
cmaloney:test_embed_pythonstartup
Open

gh-157006: Fix test_embed when PYTHONSTARTUP is set#157007
cmaloney wants to merge 1 commit into
python:mainfrom
cmaloney:test_embed_pythonstartup

Conversation

@cmaloney

@cmaloney cmaloney commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

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.

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.
Comment thread Lib/test/test_embed.py
# Windows requires at least the SYSTEMROOT environment variable to
# start Python.
env = env.copy()
env['SYSTEMROOT'] = os.environ['SYSTEMROOT']

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: SYSTEMROOT is now always kept so this line is a no-op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant