mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
extmod/vfs_lfsx: Fix import_stat so it takes into account current dir.
CPython semantics require searching the current directory if the import is not absolute (when "" is in sys.path). Fixes issue #6037.
This commit is contained in:
@@ -58,6 +58,12 @@ def test(bdev, vfs_class):
|
||||
f.write('print("package")\n')
|
||||
import lfspkg
|
||||
|
||||
# chdir and import module from current directory (needs "" in sys.path)
|
||||
uos.mkdir("/lfs/subdir")
|
||||
uos.chdir("/lfs/subdir")
|
||||
uos.rename("/lfs/lfsmod.py", "/lfs/subdir/lfsmod2.py")
|
||||
import lfsmod2
|
||||
|
||||
# umount
|
||||
uos.umount("/lfs")
|
||||
|
||||
@@ -72,6 +78,7 @@ import sys
|
||||
|
||||
sys.path.clear()
|
||||
sys.path.append("/lfs")
|
||||
sys.path.append("")
|
||||
|
||||
# run tests
|
||||
test(bdev, uos.VfsLfs1)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
test <class 'VfsLfs1'>
|
||||
hello from lfs
|
||||
package
|
||||
hello from lfs
|
||||
test <class 'VfsLfs2'>
|
||||
hello from lfs
|
||||
package
|
||||
hello from lfs
|
||||
|
||||
Reference in New Issue
Block a user