# HG changeset patch # User Yuya Nishihara # Date 2018-08-12 03:14:28 # Node ID c2327bb3505dacb61918f819c659e5cda6a89336 # Parent ebf54a34b7b747414b6a4605f33a8bfd79f698c7 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(