From 8735de7479c4c0745a1bd49cfd89f96669a6ce93 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 6 Mar 2018 16:31:03 -0800 Subject: drop bytes support from Address We don't want to be comparing bytes anyway, the decode would use utf-8, and that isn't right. Instead make the caller convert to a str of Address first. --- alot/account.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'alot/account.py') diff --git a/alot/account.py b/alot/account.py index 6cd78919..461d2bbf 100644 --- a/alot/account.py +++ b/alot/account.py @@ -102,9 +102,6 @@ class Address(object): def __str__(self): return '{}@{}'.format(self.username, self.domainname) - def __bytes__(self): - return '{}@{}'.format(self.username, self.domainname).encode('utf-8') - def __cmp(self, other, comparitor): """Shared helper for rich comparison operators. @@ -126,11 +123,6 @@ class Address(object): ouser, odomain = other.split('@') except ValueError: ouser, odomain = '', '' - elif isinstance(other, bytes): - try: - ouser, odomain = other.decode('utf-8').split('@') - except ValueError: - ouser, odomain = b'', b'' else: ouser = other.username odomain = other.domainname @@ -145,13 +137,13 @@ class Address(object): comparitor(self.domainname.lower(), odomain.lower())) def __eq__(self, other): - if not isinstance(other, (Address, (str, bytes))): - raise TypeError('Address must be compared to Address, str, or bytes') + if not isinstance(other, (Address, str)): + raise TypeError('Address must be compared to Address or str') return self.__cmp(other, operator.eq) def __ne__(self, other): - if not isinstance(other, (Address, (str, bytes))): - raise TypeError('Address must be compared to Address,str, or bytes') + if not isinstance(other, (Address, str)): + raise TypeError('Address must be compared to Address or str') # != is the only rich comparitor that cannot be implemented using 'and' # in self.__cmp, so it's implemented as not ==. return not self.__cmp(other, operator.eq) -- cgit v1.2.3