# HG changeset patch # User Denis Laxalde # Date 2019-11-13 15:46:28 # Node ID ddb5d097d5619ba197af62534d4c6d493e4cb472 # Parent af3e341dbf03745e52ea6ce98a47a0278faae3fd mail: move strtolocal call in _addressencode() diff --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -395,8 +395,8 @@ def headencode(ui, s, charsets=None, dis def _addressencode(ui, name, addr, charsets=None): - # type: (Any, str, bytes, List[str]) -> str - assert isinstance(addr, bytes) + # type: (Any, str, str, List[str]) -> str + addr = encoding.strtolocal(addr) name = headencode(ui, name, charsets) try: acc, dom = addr.split(b'@') @@ -420,7 +420,7 @@ def addressencode(ui, address, charsets= if display or not address: return encoding.strfromlocal(address or b'') name, addr = email.utils.parseaddr(encoding.strfromlocal(address)) - return _addressencode(ui, name, encoding.strtolocal(addr), charsets) + return _addressencode(ui, name, addr, charsets) def addrlistencode(ui, addrs, charsets=None, display=False): @@ -438,7 +438,7 @@ def addrlistencode(ui, addrs, charsets=N result = [] for name, addr in email.utils.getaddresses(straddrs): if name or addr: - r = _addressencode(ui, name, encoding.strtolocal(addr), charsets) + r = _addressencode(ui, name, addr, charsets) result.append(r) return result