diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-03-06 16:31:03 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-03-06 16:41:57 -0800 |
commit | 8735de7479c4c0745a1bd49cfd89f96669a6ce93 (patch) | |
tree | 3831bef0d1618ade22b9a5752956719f06f833f1 /alot/account.py | |
parent | de3be5da8510605fff09eac6029452656a245972 (diff) |
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.
Diffstat (limited to 'alot/account.py')
-rw-r--r-- | alot/account.py | 16 |
1 files changed, 4 insertions, 12 deletions
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) |