mail: import email.utils not email.Utils
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 11 Feb 2018 18:58:45 -0800
changeset 36120 54dfb65e2f82
parent 36119 6ea7f1c10c81
child 36121 3a763d7f40e1
mail: import email.utils not email.Utils 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. Differential Revision: https://phab.mercurial-scm.org/D2168
mercurial/mail.py
--- a/mercurial/mail.py	Sun Feb 11 18:50:24 2018 -0800
+++ b/mercurial/mail.py	Sun Feb 11 18:58:45 2018 -0800
@@ -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