# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1475854211 -7200
#      Fri Oct 07 17:30:11 2016 +0200
# Node ID 2a61396608bcbba3d3f4e50002b19563741d2fb5
# Parent  6ffb7e0249f44ab120b4437ae7d65020d03927ba
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

diff -r 6ffb7e0249f4 -r 2a61396608bc mercurial/mail.py
--- a/mercurial/mail.py Fri Oct 07 08:32:18 2016 -0400
+++ b/mercurial/mail.py Fri Oct 07 17:30:11 2016 +0200
@@ -23,7 +23,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 +279,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 +330,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))
diff -r 6ffb7e0249f4 -r 2a61396608bc tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t     Fri Oct 07 08:32:18 2016 -0400
+++ b/tests/test-check-py3-compat.t     Fri Oct 07 17:30:11 2016 +0200
@@ -121,7 +121,6 @@
   mercurial/i18n.py: error importing module: <TypeError> bytes expected, not 
str (line *)
   mercurial/keepalive.py: error importing module: <AttributeError> module 
'mercurial.util' has no attribute 'httplib' (line *)
   mercurial/localrepo.py: error importing: <TypeError> a bytes-like object is 
required, not 'str' (error at revset.py:*)
-  mercurial/mail.py: error importing module: <AttributeError> module 'email' 
has no attribute 'Header' (line *)
   mercurial/manifest.py: error importing: <TypeError> a bytes-like object is 
required, not 'str' (error at revset.py:*)
   mercurial/merge.py: error importing: <TypeError> a bytes-like object is 
required, not 'str' (error at revset.py:*)
   mercurial/namespaces.py: error importing: <TypeError> a bytes-like object is 
required, not 'str' (error at revset.py:*)
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to