Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WASI] test cases with sys.path.insert(0, os.curdir) fail on WASI #93461

Closed
Assignees
brettcannon
Labels
3.11only security fixes3.12only security fixestopic-importlibtype-bugAn unexpected behavior, bug, or error
@tiran

Description

@tiran

Bug report

Test cases that insertos.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('.').

 ./test-wasi.sh test_support -m test_forget0:00:00 Run tests sequentially0:00:00 [1/1] test_supporttest 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 outdatedFileFinder instance:{'.': FileFinder('/.')}. The CWD is'/python-wasm/cpython/builddir/wasi/build/test_python_66600æ' when the test case is executed.

0:00:00 [1/1] test_support> /Lib/test/test_support.py(114)test_forget()-> sys.path.insert(0, os.curdir)(Pdb) p sys.path['.', '/usr/local/lib/python312.zip', '/Lib', '/build/lib.wasi-wasm32-3.12'](Pdb) pp sys.path_importer_cache{'.': FileFinder('/.'), '/Lib': FileFinder('/Lib'), '/Lib/collections': FileFinder('/Lib/collections'), '/Lib/encodings': FileFinder('/Lib/encodings'), '/Lib/importlib': FileFinder('/Lib/importlib'), '/Lib/re': FileFinder('/Lib/re'), '/Lib/test': FileFinder('/Lib/test'), '/Lib/test/libregrtest': FileFinder('/Lib/test/libregrtest'), '/Lib/test/support': FileFinder('/Lib/test/support'), '/Lib/unittest': FileFinder('/Lib/unittest'), '/Lib/urllib': FileFinder('/Lib/urllib'), '/build/lib.wasi-wasm32-3.12': FileFinder('/build/lib.wasi-wasm32-3.12'), '/usr/local/lib/python312.zip': None}(Pdb) p os.getcwd()'/python-wasm/cpython/builddir/wasi/build/test_python_66600æ'(Pdb) n> /Lib/test/test_support.py(115)test_forget()-> importlib.invalidate_caches()(Pdb) n> /Lib/test/test_support.py(116)test_forget()-> try:(Pdb) p sys.path['.', '.', '/usr/local/lib/python312.zip', '/Lib', '/build/lib.wasi-wasm32-3.12'](Pdb) pp sys.path_importer_cache{'.': FileFinder('/.'), '/Lib': FileFinder('/Lib'), '/Lib/collections': FileFinder('/Lib/collections'), '/Lib/encodings': FileFinder('/Lib/encodings'), '/Lib/importlib': FileFinder('/Lib/importlib'), '/Lib/re': FileFinder('/Lib/re'), '/Lib/test': FileFinder('/Lib/test'), '/Lib/test/libregrtest': FileFinder('/Lib/test/libregrtest'), '/Lib/test/support': FileFinder('/Lib/test/support'), '/Lib/unittest': FileFinder('/Lib/unittest'), '/Lib/urllib': FileFinder('/Lib/urllib'), '/build/lib.wasi-wasm32-3.12': FileFinder('/build/lib.wasi-wasm32-3.12'), '/usr/local/lib/python312.zip': None}

A build on Linux has an absolute path to build directory as firstsys.path entry.

reproducer

$ podman run --rm -ti -v $(pwd):/python-wasm/cpython:Z quay.io/tiran/cpythonbuild:emsdk3# ./build-python-build.sh# ./build-python-wasi.sh# ./test-wasi.sh test_support -m test_forget

Metadata

Metadata

Assignees

Labels

3.11only security fixes3.12only security fixestopic-importlibtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2026 Movatter.jp