diff mercurial/mail.py @ 30072:87b8e40eb812

mail: handle renamed email.Header We are still using email.Header which was renamed to email.header back in Python 2.5. References: https://hg.python.org/cpython/file/2.4/Lib/email and https://hg.python.org/cpython/file/2.5/Lib/email
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 07 Oct 2016 17:30:11 +0200
parents 63a3749147af
children 040f23ed6963
line wrap: on
line diff
--- a/mercurial/mail.py	Fri Oct 07 08:32:40 2016 -0400
+++ b/mercurial/mail.py	Fri Oct 07 17:30:11 2016 +0200
@@ -8,6 +8,7 @@
 from __future__ import absolute_import, print_function
 
 import email
+import email.header
 import os
 import quopri
 import smtplib
@@ -23,7 +24,7 @@
     util,
 )
 
-_oldheaderinit = email.Header.Header.__init__
+_oldheaderinit = email.header.Header.__init__
 def _unifiedheaderinit(self, *args, **kw):
     """
     Python 2.7 introduces a backwards incompatible change
@@ -279,7 +280,7 @@
     if not display:
         # split into words?
         s, cs = _encode(ui, s, charsets)
-        return str(email.Header.Header(s, cs))
+        return str(email.header.Header(s, cs))
     return s
 
 def _addressencode(ui, name, addr, charsets=None):
@@ -330,7 +331,7 @@
 def headdecode(s):
     '''Decodes RFC-2047 header'''
     uparts = []
-    for part, charset in email.Header.decode_header(s):
+    for part, charset in email.header.decode_header(s):
         if charset is not None:
             try:
                 uparts.append(part.decode(charset))