From 7dffbfd22a128d88cd4cd7f23ebf24c46ae8791f Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 14 May 2020 21:37:59 +1000 Subject: 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. --- tests/extmod/vfs_lfs_mount.py | 7 +++++++ tests/extmod/vfs_lfs_mount.py.exp | 2 ++ 2 files changed, 9 insertions(+) (limited to 'tests/extmod') diff --git a/tests/extmod/vfs_lfs_mount.py b/tests/extmod/vfs_lfs_mount.py index 7ac19184b..9207f4a8c 100644 --- a/tests/extmod/vfs_lfs_mount.py +++ b/tests/extmod/vfs_lfs_mount.py @@ -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) diff --git a/tests/extmod/vfs_lfs_mount.py.exp b/tests/extmod/vfs_lfs_mount.py.exp index 90aff3501..b5c521531 100644 --- a/tests/extmod/vfs_lfs_mount.py.exp +++ b/tests/extmod/vfs_lfs_mount.py.exp @@ -1,6 +1,8 @@ test hello from lfs package +hello from lfs test hello from lfs package +hello from lfs -- cgit v1.2.3