Patchwork D2453: py3: use email.utils module instead of email.Utils

login
register
mail settings
Submitter phabricator
Date Feb. 26, 2018, 12:31 p.m.
Message ID <differential-rev-PHID-DREV-xxwf4w5ltt45jbzsvnzj-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28386/
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.utils as eutil
  >>>  email.Utils.parseaddr is eutil.parseaddr
  
  True
  
  >>> email.Utils.formatdate is eutil.formatdate
  
  True
  
  email.Utils is not present on Python 3.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/patchbomb.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 26, 2018, 1:16 p.m.
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> patchbomb.py:748
>  
> -    sender_addr = emailmod.Utils.parseaddr(sender)[1]
> +    sender_addr = eutil.parseaddr(pycompat.sysstr(sender))[1]
>      sender = mail.addressencode(ui, sender, _charsets, opts.get('test'))

Perhaps it should be `encoding.strfromlocal()` because `sender`
is provided from user config or argument.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, yuja
Cc: yuja, 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.utils as eutil
 import errno
 import os
 import socket
@@ -744,7 +745,7 @@ 
         if not parent.endswith('>'):
             parent += '>'
 
-    sender_addr = emailmod.Utils.parseaddr(sender)[1]
+    sender_addr = eutil.parseaddr(pycompat.sysstr(sender))[1]
     sender = mail.addressencode(ui, sender, _charsets, opts.get('test'))
     sendmail = None
     firstpatch = None
@@ -763,7 +764,7 @@ 
             parent = m['Message-Id']
 
         m['User-Agent'] = 'Mercurial-patchbomb/%s' % util.version()
-        m['Date'] = emailmod.Utils.formatdate(start_time[0], localtime=True)
+        m['Date'] = eutil.formatdate(start_time[0], localtime=True)
 
         start_time = (start_time[0] + 1, start_time[1])
         m['From'] = sender