From 92464f11b0db59456a7cf3f1181f38c200a29210 Mon Sep 17 00:00:00 2001 From: Michel Bouwmans Date: Thu, 22 Jul 2021 23:57:52 +0200 Subject: [PATCH] tools/mpremote: Raise OSError on unsupported RemoteFile.seek. Signed-off-by: Michel Bouwmans --- tools/mpremote/mpremote/pyboardextended.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/mpremote/mpremote/pyboardextended.py b/tools/mpremote/mpremote/pyboardextended.py index 6f439e2dd0..abdffb7532 100644 --- a/tools/mpremote/mpremote/pyboardextended.py +++ b/tools/mpremote/mpremote/pyboardextended.py @@ -1,4 +1,4 @@ -import os, re, serial, struct, time +import io, os, re, serial, struct, time from errno import EPERM from .console import VT_ENABLED @@ -222,6 +222,8 @@ class RemoteFile(uio.IOBase): c.wr_s8(whence) n = c.rd_s32() c.end() + if n < 0: + raise OSError(n) return n @@ -463,7 +465,10 @@ class PyboardCommand: n = self.rd_s32() whence = self.rd_s8() # self.log_cmd(f"seek {fd} {n}") - n = self.data_files[fd][0].seek(n, whence) + try: + n = self.data_files[fd][0].seek(n, whence) + except io.UnsupportedOperation: + n = -1 self.wr_s32(n) def do_write(self):