summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/vfs_userfs.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-09-05 18:18:47 +1000
committerDamien George <damien@micropython.org>2023-09-14 13:03:31 +1000
commit397697aa8368f45bd0794e22a25083e9e18e3cfe (patch)
tree0a083c8d82d3ae60d2dcdfc24e59de025732f9f8 /tests/extmod/vfs_userfs.py
parent5e122b11eaee64bbece2ace08fc3f994d5f83f2e (diff)
downloadmicropython-397697aa8368f45bd0794e22a25083e9e18e3cfe.tar.gz
micropython-397697aa8368f45bd0794e22a25083e9e18e3cfe.zip
py/persistentcode: Always close reader even if an exception is raised.
Fixes issue #3874. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/extmod/vfs_userfs.py')
-rw-r--r--tests/extmod/vfs_userfs.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/extmod/vfs_userfs.py b/tests/extmod/vfs_userfs.py
index 91c355c3df..36f1088870 100644
--- a/tests/extmod/vfs_userfs.py
+++ b/tests/extmod/vfs_userfs.py
@@ -69,6 +69,7 @@ user_files = {
"/usermod1.py": b"print('in usermod1')\nimport usermod2",
"/usermod2.py": b"print('in usermod2')",
"/usermod3.py": b"syntax error",
+ "/usermod4.mpy": b"syntax error",
}
os.mount(UserFS(user_files), "/userfs")
@@ -86,6 +87,12 @@ try:
except SyntaxError:
print("SyntaxError in usermod3")
+# import a .mpy file with a syntax error (file should be closed on error)
+try:
+ import usermod4
+except ValueError:
+ print("ValueError in usermod4")
+
# unmount and undo path addition
os.umount("/userfs")
sys.path.pop()