diff options
author | Damien George <damien@micropython.org> | 2023-09-05 18:17:27 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-09-14 13:03:31 +1000 |
commit | 5e122b11eaee64bbece2ace08fc3f994d5f83f2e (patch) | |
tree | c9cc411960d8524002c1817945168f8b1ee6d006 /tests/extmod/vfs_userfs.py | |
parent | c9089e71a1b9202aa5abefbb3c9c29659ec838ab (diff) | |
download | micropython-5e122b11eaee64bbece2ace08fc3f994d5f83f2e.tar.gz micropython-5e122b11eaee64bbece2ace08fc3f994d5f83f2e.zip |
py/parse: Always free lexer even if an exception is raised.
Fixes issue #3843.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/extmod/vfs_userfs.py')
-rw-r--r-- | tests/extmod/vfs_userfs.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/extmod/vfs_userfs.py b/tests/extmod/vfs_userfs.py index 518373c70a..91c355c3df 100644 --- a/tests/extmod/vfs_userfs.py +++ b/tests/extmod/vfs_userfs.py @@ -68,6 +68,7 @@ user_files = { "/data.txt": b"some data in a text file", "/usermod1.py": b"print('in usermod1')\nimport usermod2", "/usermod2.py": b"print('in usermod2')", + "/usermod3.py": b"syntax error", } os.mount(UserFS(user_files), "/userfs") @@ -79,6 +80,12 @@ print(f.read()) sys.path.append("/userfs") import usermod1 +# import a .py file with a syntax error (file should be closed on error) +try: + import usermod3 +except SyntaxError: + print("SyntaxError in usermod3") + # unmount and undo path addition os.umount("/userfs") sys.path.pop() |