mercurial/mail.py
changeset 39039 952bf3c948f0
parent 39037 ede768cfe83e
child 39105 f68ad9b4a43b
--- 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)