mail: call s.decode('ascii') explicitly to see if s is an ascii bytes
authorYuya Nishihara <yuya@tcha.org>
Sun, 12 Aug 2018 12:14:28 +0900
changeset 39107 c2327bb3505d
parent 39106 ebf54a34b7b7
child 39108 d2d89d31cbb5
mail: call s.decode('ascii') explicitly to see if s is an ascii bytes
mercurial/mail.py
--- a/mercurial/mail.py	Sun Aug 12 12:11:36 2018 +0900
+++ b/mercurial/mail.py	Sun Aug 12 12:14:28 2018 +0900
@@ -312,7 +312,7 @@
     name = headencode(ui, name, charsets)
     try:
         acc, dom = addr.split('@')
-        acc = acc.encode('ascii')
+        acc.decode('ascii')
         dom = dom.decode(encoding.encoding).encode('idna')
         addr = '%s@%s' % (acc, dom)
     except UnicodeDecodeError:
@@ -320,7 +320,7 @@
     except ValueError:
         try:
             # too strict?
-            addr = addr.encode('ascii')
+            addr.decode('ascii')
         except UnicodeDecodeError:
             raise error.Abort(_('invalid local address: %s') % addr)
     return pycompat.bytesurl(