[PATCH 4 of 5] mail: call s.decode('ascii') explicitly to see if s is an ascii bytes

Yuya Nishihara yuya at tcha.org
Sat Aug 11 23:27:21 EDT 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1534043668 -32400
#      Sun Aug 12 12:14:28 2018 +0900
# Node ID a160d88772ff1da51160faa5cfdbd7ecdbcd07fa
# Parent  6f357c717fa658015f5fd9c1be8e1ad9633ecddf
mail: call s.decode('ascii') explicitly to see if s is an ascii bytes

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -312,7 +312,7 @@ def _addressencode(ui, name, addr, chars
     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 @@ def _addressencode(ui, name, addr, chars
     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(


More information about the Mercurial-devel mailing list