changeset 38776:65ed2fcb9032

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
author Augie Fackler <augie@google.com>
date Mon, 16 Jul 2018 14:15:29 -0400
parents e971d6eb4770
children 83a505b5cf85
files hgext/patchbomb.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py	Mon Jul 30 14:37:36 2018 -0700
+++ b/hgext/patchbomb.py	Mon Jul 16 14:15:29 2018 -0400
@@ -780,6 +780,16 @@
             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')