Browse Source

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 <jim.mussared@gmail.com>
pull/9754/head
Jim Mussared 2 years ago
committed by Damien George
parent
commit
3427e12e8f
  1. 5
      tools/mpremote/mpremote/pyboardextended.py

5
tools/mpremote/mpremote/pyboardextended.py

@ -428,12 +428,11 @@ class PyboardCommand:
path = self.root + self.rd_str() path = self.root + self.rd_str()
try: try:
self.path_check(path) self.path_check(path)
self.data_ilistdir[0] = path
self.data_ilistdir[1] = os.listdir(path)
self.wr_s8(0) self.wr_s8(0)
except OSError as er: except OSError as er:
self.wr_s8(-abs(er.errno)) self.wr_s8(-abs(er.errno))
else:
self.data_ilistdir[0] = path
self.data_ilistdir[1] = os.listdir(path)
def do_ilistdir_next(self): def do_ilistdir_next(self):
if self.data_ilistdir[1]: if self.data_ilistdir[1]:

Loading…
Cancel
Save