gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set#151952
Merged
Conversation
…mpile, and test_inspect to neutralize PYTHONPYCACHEPREFIX
15 tasks
Member
|
test_inspect fails on Windows. Example: |
Contributor
Author
|
I will resolve this today :) |
…d_target
On Windows, os.path resolves to ntpath which is a frozen module
(origin='frozen', cached=None). Calling cache_from_source('frozen')
fabricates a nonsensical path that mismatches the subprocess output of
None. Guard the cache_from_source call on cached being non-None.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…es, fix NEWS.d with no test target
gpshead
approved these changes
Jul 1, 2026
gpshead
left a comment
Member
There was a problem hiding this comment.
nice test suite cleanup, thanks!
|
Thanks @zangjiucheng for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
Sorry, @zangjiucheng and @gpshead, I could not cleanly backport this to |
|
GH-152736 is a backport of this pull request to the 3.15 branch. |
|
Sorry, @zangjiucheng and @gpshead, I could not cleanly backport this to |
gpshead
pushed a commit
that referenced
this pull request
Jul 1, 2026
…GH-151952) (#152736) gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (GH-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) <git.jiucheng@gmail.com>
|
GH-152744 is a backport of this pull request to the 3.14 branch. |
gpshead
added a commit
that referenced
this pull request
Jul 1, 2026
…GH-151952) (#152744) 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) <git.jiucheng@gmail.com>
gpshead
added a commit
that referenced
this pull request
Jul 1, 2026
…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 <68491+gpshead@users.noreply.github.com> Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
test_inspect,test_import,test_importlib.test_util,test_py_compile, andtest_compileallassume the default__pycache__bytecode layout and fail when the suite is run with
PYTHONPYCACHEPREFIXset.sys.pycache_prefix(andPYTHONPYCACHEPREFIXforsubprocess-based tests) where that assumption is made so tests are environment-independent.
assert_python_ok()runs with-I(isolated mode), which ignores
PYTHONPYCACHEPREFIX, so the expectedcachedpath must be computed with
sys.pycache_prefix=Noneto match.