summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liechti <cliechti@gmx.net>2018-05-08 03:08:24 +0200
committerChris Liechti <cliechti@gmx.net>2018-05-08 03:08:24 +0200
commit8e45873bd66c9270d292d87eb58b54b066a896bc (patch)
tree97757b0886101d3f39ce4dc964960f11d9dfe1e3
parent27b7c8b3c275fa126b6aa6604dff3207ff2bfd67 (diff)
downloadpyserial-git-8e45873bd66c9270d292d87eb58b54b066a896bc.tar.gz
fix: compare only of the same type in list_ports_common.ListPortInfo
closes #286
-rw-r--r--serial/tools/list_ports_common.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/serial/tools/list_ports_common.py b/serial/tools/list_ports_common.py
index 122e0a2..8a1b625 100644
--- a/serial/tools/list_ports_common.py
+++ b/serial/tools/list_ports_common.py
@@ -75,9 +75,13 @@ class ListPortInfo(object):
self.hwid = self.usb_info()
def __eq__(self, other):
- return self.device == other.device
+ return isinstance(other, ListPortInfo) and self.device == other.device
def __lt__(self, other):
+ if not isinstance(other, ListPortInfo):
+ raise TypeError('unorderable types: {}() and {}()'.format(
+ type(self).__name__,
+ type(other).__name__))
return numsplit(self.device) < numsplit(other.device)
def __str__(self):