diff --git a/hgext/notify.py b/hgext/notify.py --- a/hgext/notify.py +++ b/hgext/notify.py @@ -430,14 +430,14 @@ class notifier(object): sender = self.ui.config(b'email', b'from') or self.ui.username() if b'@' not in sender or b'@localhost' in sender: sender = self.fixmail(sender) - msg['From'] = encoding.strfromlocal( - mail.addressencode(self.ui, sender, self.charsets, self.test) + msg['From'] = mail.addressencode( + self.ui, sender, self.charsets, self.test ) msg['X-Hg-Notification'] = 'changeset %s' % ctx if not msg['Message-Id']: msg['Message-Id'] = messageid(ctx, self.domain, self.messageidseed) - msg['To'] = encoding.strfromlocal(b', '.join(sorted(subs))) + msg['To'] = ', '.join(sorted(subs)) msgtext = msg.as_bytes() if pycompat.ispy3 else msg.as_string() if self.test: diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -943,13 +943,13 @@ def email(ui, repo, *revs, **opts): start_time = (start_time[0] + 1, start_time[1]) m[b'From'] = sender - m[b'To'] = b', '.join(to) + m[b'To'] = ', '.join(to) if cc: - m[b'Cc'] = b', '.join(cc) + m[b'Cc'] = ', '.join(cc) if bcc: - m[b'Bcc'] = b', '.join(bcc) + m[b'Bcc'] = ', '.join(bcc) if replyto: - m[b'Reply-To'] = b', '.join(replyto) + m[b'Reply-To'] = ', '.join(replyto) # Fix up all headers to be native strings. # TODO(durin42): this should probably be cleaned up above in the future. if pycompat.ispy3: @@ -992,7 +992,6 @@ def email(ui, repo, *revs, **opts): generator = mail.Generator(fp, mangle_from_=False) generator.flatten(m, 0) alldests = to + bcc + cc - alldests = [encoding.strfromlocal(d) for d in alldests] sendmail(sender_addr, alldests, fp.getvalue()) progress.complete() diff --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -385,15 +385,13 @@ def _addressencode(ui, name, addr, chars addr.decode('ascii') except UnicodeDecodeError: raise error.Abort(_(b'invalid local address: %s') % addr) - return pycompat.bytesurl( - email.utils.formataddr((name, encoding.strfromlocal(addr))) - ) + return email.utils.formataddr((name, encoding.strfromlocal(addr))) def addressencode(ui, address, charsets=None, display=False): '''Turns address into RFC-2047 compliant header.''' if display or not address: - return address or b'' + return encoding.strfromlocal(address or b'') name, addr = email.utils.parseaddr(encoding.strfromlocal(address)) return _addressencode(ui, name, encoding.strtolocal(addr), charsets) @@ -405,7 +403,7 @@ def addrlistencode(ui, addrs, charsets=N for a in addrs: assert isinstance(a, bytes), '%r unexpectedly not a bytestr' % a if display: - return [a.strip() for a in addrs if a.strip()] + return [encoding.strfromlocal(a.strip()) for a in addrs if a.strip()] result = [] for name, addr in email.utils.getaddresses(