diff --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -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)