changeset 39107:c2327bb3505d

mail: call s.decode('ascii') explicitly to see if s is an ascii bytes
author Yuya Nishihara <yuya@tcha.org>
date Sun, 12 Aug 2018 12:14:28 +0900
parents ebf54a34b7b7
children d2d89d31cbb5
files mercurial/mail.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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(