mail: convert addr to str early in addrlistencode()
authorDenis Laxalde <denis@laxalde.org>
Sat, 09 Nov 2019 16:54:33 +0100
changeset 43577 599e25add437
parent 43576 14b96072797d
child 43578 cbcd72844df1
mail: convert addr to str early in addrlistencode()
mercurial/mail.py
--- a/mercurial/mail.py	Sat Nov 09 15:16:52 2019 +0100
+++ b/mercurial/mail.py	Sat Nov 09 16:54:33 2019 +0100
@@ -400,15 +400,15 @@
     '''Turns a list of addresses into a list of RFC-2047 compliant headers.
     A single element of input list may contain multiple addresses, but output
     always has one address per item'''
+    straddrs = []
     for a in addrs:
         assert isinstance(a, bytes), '%r unexpectedly not a bytestr' % a
+        straddrs.append(encoding.strfromlocal(a))
     if display:
-        return [encoding.strfromlocal(a.strip()) for a in addrs if a.strip()]
+        return [a.strip() for a in straddrs if a.strip()]
 
     result = []
-    for name, addr in email.utils.getaddresses(
-        [encoding.strfromlocal(a) for a in addrs]
-    ):
+    for name, addr in email.utils.getaddresses(straddrs):
         if name or addr:
             r = _addressencode(ui, name, encoding.strtolocal(addr), charsets)
             result.append(r)