Skip to content

test_sysconfig leaves the sysconfig prefix cache modified #155726

Closed

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

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    3.16new features, bugs and security fixes
    on Aug 13, 2026
  2. added a commit that references this issue on Aug 14, 2026
  3. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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