Skip to content

Commit 12ee3ce

Browse files
committed
Return None from MbedTerminal Constructor
Since we examine `self.serial` to determine the success of the constructor, I made all `return False` statements within the constructor set `self.serial = None`. That way the current code should catch the failures without any additional changes Fixes #688
1 parent e89c68a commit 12ee3ce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mbed/mbed_terminal.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@ def __init__(self, port, baudrate=9600, echo=True, timeout=10):
3535
try:
3636
from serial import Serial, SerialException
3737
except (IOError, ImportError, OSError):
38-
return False
38+
self.serial = None
39+
return
3940

4041
try:
4142
self.serial = Serial(self.port, baudrate=self.baudrate, timeout=self.timeout)
4243
self.serial.flush()
4344
self.serial.reset_input_buffer()
4445
except Exception as e:
4546
self.serial = None
46-
return False
47+
return
4748

4849
def terminal(self, print_header=True):
4950
try:

0 commit comments

Comments
 (0)