Fix UnboundLocalError in MIDI handler when pyserial is missing
- Remove serial.SerialException from except clause since 'serial' is not defined when import serial fails, causing UnboundLocalError - Catch only ImportError and OSError
This commit is contained in:
+1
-1
@@ -165,7 +165,7 @@ class UARTMIDI(MIDIInterface):
|
||||
)
|
||||
logger.info("UART MIDI opened on %s", self._port_name)
|
||||
return True
|
||||
except (ImportError, OSError, serial.SerialException) as e:
|
||||
except (ImportError, OSError) as e:
|
||||
logger.error("UART MIDI open failed: %s", e)
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user