mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
extmod/vfs: Add finaliser to ilistdir to close directory handle.
When iterating over filesystem/folders with os.iterdir(), an open file (directory) handle is used internally. Currently this file handle is only closed once the iterator is completely drained, eg. once all entries have been looped over / converted into list etc. If a program opens an iterdir but does not loop over it, or starts to loop over the iterator but breaks out of the loop, then the handle never gets closed. In this state, when the iter object is cleaned up by the garbage collector this open handle can cause corruption of the filesystem. Fixes issues #6568 and #8506.
This commit is contained in:
committed by
Damien George
parent
582b3e4e78
commit
4e0964b59f
@@ -632,7 +632,7 @@ function ci_unix_qemu_mips_run_tests {
|
||||
# - (i)listdir does not work, it always returns the empty list (it's an issue with the underlying C call)
|
||||
# - ffi tests do not work
|
||||
file ./ports/unix/build-coverage/micropython
|
||||
(cd tests && MICROPY_MICROPYTHON=../ports/unix/build-coverage/micropython ./run-tests.py --exclude 'vfs_posix.py' --exclude 'ffi_(callback|float|float2).py')
|
||||
(cd tests && MICROPY_MICROPYTHON=../ports/unix/build-coverage/micropython ./run-tests.py --exclude 'vfs_posix.*\.py' --exclude 'ffi_(callback|float|float2).py')
|
||||
}
|
||||
|
||||
function ci_unix_qemu_arm_setup {
|
||||
@@ -652,7 +652,7 @@ function ci_unix_qemu_arm_run_tests {
|
||||
# - (i)listdir does not work, it always returns the empty list (it's an issue with the underlying C call)
|
||||
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabi
|
||||
file ./ports/unix/build-coverage/micropython
|
||||
(cd tests && MICROPY_MICROPYTHON=../ports/unix/build-coverage/micropython ./run-tests.py --exclude 'vfs_posix.py')
|
||||
(cd tests && MICROPY_MICROPYTHON=../ports/unix/build-coverage/micropython ./run-tests.py --exclude 'vfs_posix.*\.py')
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
|
||||
Reference in New Issue
Block a user