D3951: patchbomb: work around email module really wanting to write unicode data

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Thu Aug 9 22:57:33 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb95538a21613: patchbomb: work around email module really wanting to write unicode data (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3951?vs=10189&id=10244

REVISION DETAIL
  https://phab.mercurial-scm.org/D3951

AFFECTED FILES
  hgext/patchbomb.py

CHANGE DETAILS

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -139,6 +139,11 @@
     default=None,
 )
 
+if pycompat.ispy3:
+    _bytesgenerator = emailgen.BytesGenerator
+else:
+    _bytesgenerator = lambda f: f
+
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
@@ -793,7 +798,8 @@
         if opts.get('test'):
             ui.status(_('displaying '), subj, ' ...\n')
             ui.pager('email')
-            generator = emailgen.Generator(ui, mangle_from_=False)
+            generator = emailgen.Generator(_bytesgenerator(ui),
+                                           mangle_from_=False)
             try:
                 generator.flatten(m, 0)
                 ui.write('\n')
@@ -809,7 +815,8 @@
                 # Exim does not remove the Bcc field
                 del m['Bcc']
             fp = stringio()
-            generator = emailgen.Generator(fp, mangle_from_=False)
+            generator = emailgen.Generator(_bytesgenerator(fp),
+                                           mangle_from_=False)
             generator.flatten(m, 0)
             sendmail(sender_addr, to + bcc + cc, fp.getvalue())
 



To: durin42, #hg-reviewers, indygreg
Cc: mjpieters, indygreg, yuja, mercurial-devel


More information about the Mercurial-devel mailing list