Skip to content

test_sysconfig leaves the sysconfig prefix cache modified #155726

Description

@serhiy-storchaka

Bug report

TestSysConfig.tearDown() restores sysconfig._CONFIG_VARS, but not sysconfig._config_vars_cached_prefix and sysconfig._config_vars_cached_exec_prefix.

test_sysconfig_config_vars_no_prefix_cache sets sys.prefix to 'prefix-BBB' and calls get_config_vars(), so the cached prefix keeps that value after the test. The next get_config_vars() call finds the cache stale and replaces _CONFIG_VARS with a new dict:

cached prefix before: /usr/local
cached prefix after : prefix-BBB
rebuilt: True

regrtest reports this as Warning -- sysconfig._CONFIG_VARS was modified by test_sysconfig, because its own check calls sysconfig.get_config_var('prefix') before comparing:

$ ./python -m test --fail-env-changed test_sysconfig -m test_sysconfig_config_vars_no_prefix_cache
Result: ENV CHANGED

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.16new features, bugs and security fixestestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions