Skip to content

Commit 8e45873

Browse files
committed
fix: compare only of the same type in list_ports_common.ListPortInfo
closes pyserial#286
1 parent 27b7c8b commit 8e45873

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

serial/tools/list_ports_common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ def apply_usb_info(self):
7575
self.hwid = self.usb_info()
7676

7777
def __eq__(self, other):
78-
return self.device == other.device
78+
return isinstance(other, ListPortInfo) and self.device == other.device
7979

8080
def __lt__(self, other):
81+
if not isinstance(other, ListPortInfo):
82+
raise TypeError('unorderable types: {}() and {}()'.format(
83+
type(self).__name__,
84+
type(other).__name__))
8185
return numsplit(self.device) < numsplit(other.device)
8286

8387
def __str__(self):

0 commit comments

Comments
 (0)