Patchwork D2454: py3: use email.generator module instead of email.Generator

login
register
mail settings
Submitter phabricator
Date Feb. 26, 2018, 12:31 p.m.
Message ID <differential-rev-PHID-DREV-huormh3fokd5p4jl4zml-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28387/
State Superseded
Headers show

Comments

phabricator - Feb. 26, 2018, 12:31 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  On py2:
  
  >>> import email
  >>>  import email.generator as emailgen
  >>>  email.Generator.Generator is emailgen.Generator
  
  True
  
  email.Generator is not present on Python 3.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/patchbomb.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -74,6 +74,7 @@ 
 from __future__ import absolute_import
 
 import email as emailmod
+import email.generator as emailgen
 import email.utils as eutil
 import errno
 import os
@@ -778,7 +779,7 @@ 
         if opts.get('test'):
             ui.status(_('displaying '), subj, ' ...\n')
             ui.pager('email')
-            generator = emailmod.Generator.Generator(ui, mangle_from_=False)
+            generator = emailgen.Generator(ui, mangle_from_=False)
             try:
                 generator.flatten(m, 0)
                 ui.write('\n')
@@ -795,7 +796,7 @@ 
                 # Exim does not remove the Bcc field
                 del m['Bcc']
             fp = stringio()
-            generator = emailmod.Generator.Generator(fp, mangle_from_=False)
+            generator = emailgen.Generator(fp, mangle_from_=False)
             generator.flatten(m, 0)
             sendmail(sender_addr, to + bcc + cc, fp.getvalue())