changeset 43577:599e25add437

mail: convert addr to str early in addrlistencode()
author Denis Laxalde <denis@laxalde.org>
date Sat, 09 Nov 2019 16:54:33 +0100
parents 14b96072797d
children cbcd72844df1
files mercurial/mail.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)