Patchwork D2168: mail: import email.utils not email.Utils

login
register
mail settings
Submitter phabricator
Date Feb. 12, 2018, 3:45 a.m.
Message ID <differential-rev-PHID-DREV-ibtt7cr5ek6s7cheau5i-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27637/
State Superseded
Headers show

Comments

phabricator - Feb. 12, 2018, 3:45 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  email.Utils was renamed to email.utils in Python 2.5. But it appears
  at some point before Python 2.7 (possibly 2.5) email.Utils was aliased
  to the new home. So email.utils should be safe for all versions of
  Python we support.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/mail.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -288,13 +288,13 @@ 
             addr = addr.encode('ascii')
         except UnicodeDecodeError:
             raise error.Abort(_('invalid local address: %s') % addr)
-    return email.Utils.formataddr((name, addr))
+    return email.utils.formataddr((name, addr))
 
 def addressencode(ui, address, charsets=None, display=False):
     '''Turns address into RFC-2047 compliant header.'''
     if display or not address:
         return address or ''
-    name, addr = email.Utils.parseaddr(address)
+    name, addr = email.utils.parseaddr(address)
     return _addressencode(ui, name, addr, charsets)
 
 def addrlistencode(ui, addrs, charsets=None, display=False):
@@ -305,7 +305,7 @@ 
         return [a.strip() for a in addrs if a.strip()]
 
     result = []
-    for name, addr in email.Utils.getaddresses(addrs):
+    for name, addr in email.utils.getaddresses(addrs):
         if name or addr:
             result.append(_addressencode(ui, name, addr, charsets))
     return result