From 3427e12e8f3879bb5d285a6d379744ffadd8e986 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Wed, 26 Oct 2022 22:03:46 +1100 Subject: [PATCH] tools/mpremote: Handle FileNotFound exceptions in listdir. The except handler for OSError didn't include the line that actually calls os.listdir, so an invalid path wasn't handled correctly. Signed-off-by: Jim Mussared --- tools/mpremote/mpremote/pyboardextended.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/mpremote/mpremote/pyboardextended.py b/tools/mpremote/mpremote/pyboardextended.py index d3b4cb6d8..075b95ae5 100644 --- a/tools/mpremote/mpremote/pyboardextended.py +++ b/tools/mpremote/mpremote/pyboardextended.py @@ -428,12 +428,11 @@ class PyboardCommand: path = self.root + self.rd_str() try: self.path_check(path) + self.data_ilistdir[0] = path + self.data_ilistdir[1] = os.listdir(path) self.wr_s8(0) except OSError as er: self.wr_s8(-abs(er.errno)) - else: - self.data_ilistdir[0] = path - self.data_ilistdir[1] = os.listdir(path) def do_ilistdir_next(self): if self.data_ilistdir[1]: