Skip to content

Commit 7aa357a

Browse files
committed
Reduce redundancy in MbedTerminal constructor
Since the prior commit made it impossible to distinguish between these 2 types of failure, I lumped them all into a single `try` so that they can share logic. It's a bit shorted this way
1 parent 12ee3ce commit 7aa357a

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

mbed/mbed_terminal.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,10 @@ def __init__(self, port, baudrate=9600, echo=True, timeout=10):
3434

3535
try:
3636
from serial import Serial, SerialException
37-
except (IOError, ImportError, OSError):
38-
self.serial = None
39-
return
40-
41-
try:
4237
self.serial = Serial(self.port, baudrate=self.baudrate, timeout=self.timeout)
4338
self.serial.flush()
4439
self.serial.reset_input_buffer()
45-
except Exception as e:
40+
except (IOError, ImportError, OSError, Exception):
4641
self.serial = None
4742
return
4843

0 commit comments

Comments
 (0)