mail: be more cautious about bytes vs str for py3 compat
It's suboptimal that we get a bytes on 2 and a unicode on 3, but it's
easy to work with and I'm disinclined to change anything unless we
start using some sort of type inferencer.
Differential Revision: https://phab.mercurial-scm.org/D4233
--- a/mercurial/mail.py Thu Aug 09 21:57:46 2018 -0400
+++ b/mercurial/mail.py Thu Aug 09 21:58:43 2018 -0400
@@ -312,7 +312,9 @@
try:
acc, dom = addr.split(r'@')
acc = acc.encode('ascii')
- dom = dom.decode(encoding.encoding).encode('idna')
+ if isinstance(dom, bytes):
+ dom = dom.decode(encoding.encoding)
+ dom = dom.encode('idna')
addr = '%s@%s' % (acc, dom)
except UnicodeDecodeError:
raise error.Abort(_('invalid email address: %s') % addr)