mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
py/persistentcode: Always close reader even if an exception is raised.
Fixes issue #3874. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -15,3 +15,9 @@ stat /usermod3.py
|
||||
open /usermod3.py rb
|
||||
ioctl 4 0
|
||||
SyntaxError in usermod3
|
||||
stat /usermod4
|
||||
stat /usermod4.py
|
||||
stat /usermod4.mpy
|
||||
open /usermod4.mpy rb
|
||||
ioctl 4 0
|
||||
ValueError in usermod4
|
||||
|
||||
Reference in New Issue
Block a user