Uh oh!
There was an error while loading. Please reload this page.
gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set - #151952
Conversation
…mpile, and test_inspect to neutralize PYTHONPYCACHEPREFIX
vstinner
commented
Jun 23, 2026
test_inspect fails on Windows. Example: |
zangjiucheng
commented
Jun 23, 2026
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
left a comment
There was a problem hiding this comment.
nice test suite cleanup, thanks!
Uh oh!
There was an error while loading. Please reload this page.
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 |
…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. |
…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>
…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>
* main: (266 commits) pythongh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (pythonGH-151952) pythongh-152728: IDLE - move 3 toplevel fix_xyz functions to idlelb.util (python#152729) pythongh-152711: Add pythoninfo-build command to Platforms/Android (python#152713) pythongh-152715: Add pythoninfo-build command to Platforms/Apple (python#152716) pythongh-152433: Windows: enable mmapmodule for UWP (python#152473) pythongh-152433: Windows: use GetFileSizeEx instead of GetFileSize for memory mapped files (python#152383) pythonGH-81881: Raise `SpecialFileError` for sockets and devices in `shutil.copyfile` (python#142693) pythongh-152502: Detect the curses mouse interface and is_* methods portably (pythonGH-152705) pythongh-145857: Replace `DELETE_GLOBAL` with `PUSH_NULL; STORE_GLOBAL` (pythonGH-146314) pythongh-145854: Replace `DELETE_NAME` with `PUSH_NULL; STORE_NAME` (pythonGH-146006) pythongh-152680: Detect container/VM in test.pythoninfo (python#152668) pythongh-152682: Fix NULL dereference on OOM in `symtable_visit_type_param_bound_or_default` (python#152684) pythongh-151881: Skip tk_inactive negativity check on Windows (pythonGH-152683) pythongh-152546: Refactor `mappingproxy.__new__` to use `PyDictProxy_New` (python#152547) pythongh-151126: Fix a possible crash during the startup with no memory under `Py_STACKREF_DEBUG` (python#152478) pythongh-152635: Raise MemoryError when the lock allocation fails in `_interpchannels.create()` (python#152642) pythongh-151029: Fix `test_remote_exec_deleted_static_executable` on static installed builds (pythonGH-152653) pythongh-121249: Deprecate using F/D type codes in the struct module (python#152309) pythongh-152192: Fix JUMP_BACKWARD passing a truncated oparg to the jit tracer (pythonGH-152382) Don't require the `_test{internal}capi` modules in `test_monitoring.py` (python#152311) ...
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.