Skip to content

gh-155726: Restore the sysconfig prefix cache in test_sysconfig - #155729

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:test-sysconfig-config-vars-cache
Aug 14, 2026
Merged

gh-155726: Restore the sysconfig prefix cache in test_sysconfig#155729
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:test-sysconfig-config-vars-cache

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 13, 2026

Copy link
Copy Markdown
Member

Save and restore sysconfig._config_vars_cached_prefix and sysconfig._config_vars_cached_exec_prefix in TestSysConfig.

test_sysconfig_config_vars_no_prefix_cache changes sys.prefix and calls
get_config_vars(), which caches the new prefix in module globals.
tearDown() restored sysconfig._CONFIG_VARS, but not those globals, so the
next get_config_vars() call found the cache stale and replaced
_CONFIG_VARS with a new dict.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. It does fix the test as expected.

@serhiy-storchaka
serhiy-storchaka merged commit b42025d into python:main Aug 14, 2026
58 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the test-sysconfig-config-vars-cache branch August 14, 2026 04:41
mbeijen pushed a commit to mbeijen/cpython that referenced this pull request Aug 14, 2026
…pythonGH-155729)

test_sysconfig_config_vars_no_prefix_cache changes sys.prefix and calls
get_config_vars(), which caches the new prefix in module globals.
tearDown() restored sysconfig._CONFIG_VARS, but not those globals, so the
next get_config_vars() call found the cache stale and replaced
_CONFIG_VARS with a new dict.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants