# HG changeset patch # User Augie Fackler # Date 2018-08-09 22:27:36 # Node ID 2cf3bd4ae55e0b98282e2e490d3c3d5cabedd5c2 # Parent 1eb779a86c4ea38153f3818a448c6db8b2822fb1 mail: properly handle email addresses typically being unicodes Visible progress in test-patchbomb.t on Python 3. Differential Revision: https://phab.mercurial-scm.org/D4221 diff --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -152,8 +152,9 @@ def _smtp(ui): def _sendmail(ui, sender, recipients, msg): '''send mail using sendmail.''' program = ui.config('email', 'method') - cmdline = '%s -f %s %s' % (program, stringutil.email(sender), - ' '.join(map(stringutil.email, recipients))) + stremail = lambda x: stringutil.email(encoding.strtolocal(x)) + cmdline = '%s -f %s %s' % (program, stremail(sender), + ' '.join(map(stremail, recipients))) ui.note(_('sending mail: %s\n') % cmdline) fp = procutil.popen(cmdline, 'wb') fp.write(util.tonativeeol(msg)) @@ -169,7 +170,8 @@ def _mbox(mbox, sender, recipients, msg) # Should be time.asctime(), but Windows prints 2-characters day # of month instead of one. Make them print the same thing. date = time.strftime(r'%a %b %d %H:%M:%S %Y', time.localtime()) - fp.write('From %s %s\n' % (sender, date)) + fp.write('From %s %s\n' % (encoding.strtolocal(sender), + encoding.strtolocal(date))) fp.write(msg) fp.write('\n\n') fp.close()