mail: move strtolocal call in _addressencode()
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 13 Nov 2019 16:46:28 +0100
changeset 43628 ddb5d097d561
parent 43627 af3e341dbf03
child 43629 ec53ea01c9e6
mail: move strtolocal call in _addressencode()
mercurial/mail.py
--- a/mercurial/mail.py	Wed Nov 13 15:23:04 2019 +0100
+++ b/mercurial/mail.py	Wed Nov 13 16:46:28 2019 +0100
@@ -395,8 +395,8 @@
 
 
 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 @@
     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 @@
     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