Test cases that insert os.curdir ('.') into sys.path fail on WASI platforms. I think it is related how wasmtime maps directories into the runtime environment and how it sets up the current working directory. The test passes if I replace '.' with an empty string '' or remove the cached FileFinder instance for '.' with sys.path_importer_cache.pop('.').
./test-wasi.sh test_support -m test_forget
0:00:00 Run tests sequentially
0:00:00 [1/1] test_support
test test_support failed -- Traceback (most recent call last):
File "/Lib/test/test_support.py", line 116, in test_forget
mod = __import__(TESTFN)
^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '@test_66600_tmpæ'
test_support failed (1 error)
== Tests result: FAILURE ==
The culprit seems to be an outdated FileFinder instance: {'.': FileFinder('/.')}. The CWD is '/python-wasm/cpython/builddir/wasi/build/test_python_66600æ' when the test case is executed.
GH-93461 is the simplest solution I could come up with. importlib.invalidate_caches now drops all FileFinder instances if the cache key is not an absolute path.
Bug report
Test cases that insert
os.curdir
('.'
) intosys.path
fail on WASI platforms. I think it is related how wasmtime maps directories into the runtime environment and how it sets up the current working directory. The test passes if I replace'.'
with an empty string''
or remove the cachedFileFinder
instance for'.'
withsys.path_importer_cache.pop('.')
.The culprit seems to be an outdated
FileFinder
instance:{'.': FileFinder('/.')}
. The CWD is'/python-wasm/cpython/builddir/wasi/build/test_python_66600æ'
when the test case is executed.A build on Linux has an absolute path to build directory as first
sys.path
entry.reproducer
The text was updated successfully, but these errors were encountered: