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 — [3.14] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (GH-151952) by gpshead · Pull Request #152744 · python/cpython

Conversation

@gpshead

@gpshead gpshead commented Jul 1, 2026

Copy link
Copy Markdown
Member

Fix tests in test_compileall, test_import, test_importlib, test_py_compile, and test_inspect to neutralize PYTHONPYCACHEPREFIX
(cherry picked from commit 564c58c)

Co-authored-by: Jiucheng(Oliver) [email protected]

  • Issue: Some tests fail when __pycache__ prefix is set #151626

Manual backport notes (3.14)

miss-islington could not cleanly backport this to 3.14 due to a conflict in Lib/test/test_inspect/test_inspect.py. The 3.14 branch predates the python -m inspect --details CLI test refactor that exists on main/3.15 (it still has the simpler TestMain.test_details rather than TestModuleCLI with the test_details_option_with_*/test_get_cli_details_for_* suite).

The fix was translated to 3.14's dialect:

  • The _expected_cached() helper was added verbatim from the original PR, in TestMain.
  • It was applied to the single TestMain.test_details, replacing the environment-dependent module.__spec__.cached check. The redundant self.assertIn(module.__cached__, output) line (same pyc path, and itself failing under PYTHONPYCACHEPREFIX) was dropped.
  • None of the main-only test machinery was pulled in.

The other four files and the NEWS entry cherry-picked cleanly (identical hunks to the original).

Verified: test_inspect, test_compileall, test_import, test_importlib, and test_py_compile all pass both normally and with PYTHONPYCACHEPREFIX set; make patchcheck is clean.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@zangjiucheng @gpshead
[3.14] pythongh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX …
ce33758
…is set (pythonGH-151952)

Fix tests in test_compileall, test_import, test_importlib, test_py_compile, and test_inspect to neutralize PYTHONPYCACHEPREFIX
(cherry picked from commit 564c58c)

Co-authored-by: Jiucheng(Oliver) <[email protected]>
@gpshead gpshead self-assigned this Jul 1, 2026
This was referenced Jul 1, 2026
Some tests fail when __pycache__ prefix is set #151626
Closed
gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set #151952
Merged
@gpshead gpshead added the needs backport to 3.13 only security fixes label Jul 1, 2026
@gpshead
gpshead marked this pull request as ready for review July 1, 2026 07:53
@gpshead
gpshead requested review from brettcannon, ericsnowcurrently, ncoghlan and warsaw as code owners July 1, 2026 07:53
@bedevere-app bedevere-app Bot added the awaiting core review label Jul 1, 2026
@gpshead
gpshead merged commit 7087839 into python:3.14 Jul 1, 2026
51 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting core review label Jul 1, 2026
@miss-islington-app

miss-islington-app Bot commented Jul 1, 2026

Copy link
Copy Markdown

Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Jul 1, 2026

Copy link
Copy Markdown

GH-152748 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jul 1, 2026
gpshead added a commit that referenced this pull request Jul 1, 2026
@miss-islington @gpshead @zangjiucheng
[3.13] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (…
5bf5eea
…GH-151952) (GH-152744) (#152748)

[3.14] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (GH-151952) (GH-152744)

Fix tests in test_compileall, test_import, test_importlib, test_py_compile, and test_inspect to neutralize PYTHONPYCACHEPREFIX
(cherry picked from commit 564c58c)
(cherry picked from commit 7087839)

Co-authored-by: Gregory P. Smith <[email protected]>
Co-authored-by: Jiucheng(Oliver) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@brettcannon brettcannon Awaiting requested review from brettcannon brettcannon is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan ncoghlan is a code owner
@warsaw warsaw Awaiting requested review from warsaw warsaw is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gpshead gpshead

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@gpshead @zangjiucheng
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.