From d865ca53b53aca5c66028970f7321e0766a0dd58 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Fri, 28 Jan 2022 14:43:17 +1100 Subject: [PATCH] tools/mpremote: Make ConsolePosix work without .raw attribute. When running mpremote in the vscode terminal on OSX the sys.stdout.buffer does not have the raw attribute. It works fine without it. --- tools/mpremote/mpremote/console.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/mpremote/mpremote/console.py b/tools/mpremote/mpremote/console.py index 2652c7393b..a0ee55dce9 100644 --- a/tools/mpremote/mpremote/console.py +++ b/tools/mpremote/mpremote/console.py @@ -11,8 +11,13 @@ except ImportError: class ConsolePosix: def __init__(self): self.infd = sys.stdin.fileno() - self.infile = sys.stdin.buffer.raw - self.outfile = sys.stdout.buffer.raw + self.infile = sys.stdin.buffer + self.outfile = sys.stdout.buffer + if hasattr(self.infile, "raw"): + self.infile = self.infile.raw + if hasattr(self.outfile, "raw"): + self.outfile = self.outfile.raw + self.orig_attr = termios.tcgetattr(self.infd) def enter(self):