# HG changeset patch # User Augie Fackler # Date 2018-07-16 18:15:29 # Node ID 65ed2fcb9032ae3822fbaf5aac50d8feb0f35cbf # Parent e971d6eb47708bc16f67c3c9a71f434797d2ba9a patchbomb: ensure all headers and values given to email mod are native strings This lets test-patch-bookmark.t only fail with some harmless header output changes on Python 3, so I think patchbomb might be basically useful on Python 3 now. Differential Revision: https://phab.mercurial-scm.org/D3952 diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -780,6 +780,16 @@ def email(ui, repo, *revs, **opts): m['Bcc'] = ', '.join(bcc) if replyto: m['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: + for hdr, val in list(m.items()): + if isinstance(hdr, bytes): + del m[hdr] + hdr = pycompat.strurl(hdr) + if isinstance(val, bytes): + val = pycompat.strurl(val) + m[hdr] = val if opts.get('test'): ui.status(_('displaying '), subj, ' ...\n') ui.pager('email')