GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Some tests fail when __pycache__ prefix is set · Issue #151626 · python/cpython

Some tests fail when __pycache__ prefix is set #151626

New issue
Copy link
New issue
Copy link
Closed
Closed
Some tests fail when __pycache__ prefix is set#151626
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@ringobanana-3900
ringobanana-3900
opened on Jun 18, 2026
Issue body actions

Bug report

Bug description:

Some tests that check .pyc files creation are failing when sys.pycache_prefix is set.

List of tests that failed on Arm64 MacOS (maybe there's more in skipped ones):

  • test.test_inspect.test_inspect.TestModuleCLI.test_details_option_with_package
  • test.test_import.PycacheTests.test_import_pyc_path
  • test.test_import.PycacheTests.test_unwritable_directory
  • test.test_importlib.test_util.PEP3147Tests.test_cache_from_source
  • test.test_importlib.test_util.PEP3147Tests.test_cache_from_source_cwd
  • test.test_importlib.test_util.PEP3147Tests.test_cache_from_source_no_dot
  • test.test_importlib.test_util.PEP3147Tests.test_cache_from_source_optimization_None
  • test.test_importlib.test_util.PEP3147Tests.test_cache_from_source_optimization_empty_string
  • test.test_importlib.test_util.PEP3147Tests.test_cache_from_source_optimization_set
  • test.test_importlib.test_util.PEP3147Tests.test_cache_from_source_path_like_arg
  • test.test_py_compile.PyCompileCLITestCase.test_with_files
  • test.test_py_compile.PyCompileTestsBase.test_double_dot_no_clobber
  • test.test_compileall.CompileallTestsBase.test_include_on_stdin
  • test.test_compileall.CompileallTestsBase.test_multiple_runs
  • test.test_compileall.CompileallTestsBase.test_symlink_loop

example: PYTHONPYCACHEPREFIX="$HOME/__pycache__" ./python.exe -m test test.test_compileall test.test_import test.test_importlib.test_util test.test_inspect.test_inspect test.test_py_compile -v

output (edited for clarity and length): testres.txt

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

  • gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set #151952
  • [3.15] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (GH-151952) #152736
  • [3.14] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (GH-151952) #152744
  • [3.13] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (GH-151952) (GH-152744) #152748

Activity

  1. ringobanana-3900
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jun 18, 2026
  2. ringobanana-3900
    changed the title [-]Some tests fail when \_\_pycache\_\_ prefix is set[/-] [+]Some tests fail when __pycache__ prefix is set[/+] on Jun 18, 2026
  3. ZeroIntensity
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Jun 18, 2026
  4. zangjiucheng commented on Jun 22, 2026

    @zangjiucheng
    zangjiucheng
    on Jun 22, 2026
    Contributor
    More actions

    Hey there, thanks for the detailed report and the reproduction command. Verified locally on macOS ARM64 (Python 3.16.0a0) with PYTHONPYCACHEPREFIX set to a temp directory.

    The fix neutralizes sys.pycache_prefix (and strips PYTHONPYCACHEPREFIX from subprocess environments) in all five test files. Verified locally on macOS ARM64 with PYTHONPYCACHEPREFIX set; all the tests you listed now pass, including the three test_inspect.TestModuleCLI cases and the full PEP3147Tests suite.

    I will resolve and attach the PR asap.

  5. zangjiucheng
    added a commit that references this issue on Jun 23, 2026

    fix(pythongh-151626): handle frozen os.path on Windows in test_aliase…

    fdc59f3
  6. gpshead
    added 2 commits that reference this issue on Jul 1, 2026

    gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (GH-15…

    564c58c

    [3.15] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (…

    4bacb0c
  7. gpshead commented on Jul 1, 2026

    @gpshead
    gpshead
    on Jul 1, 2026
    Member
    More actions

    thanks!

  8. gpshead
    closed this as completedon Jul 1, 2026
  9. gpshead
    added 2 commits that reference this issue on Jul 1, 2026

    [3.14] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (…

    7087839

    [3.13] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (…

    5bf5eea
  10. maurycy
    added a commit that references this issue on Jul 1, 2026

    Merge branch 'main' into maurycy/bye-abba

    da7d768
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

    testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.