Patchwork mail: handle renamed email.Header

login
register
mail settings
Submitter Augie Fackler
Date Oct. 8, 2016, 10:01 a.m.
Message ID <690E2D5F-81A2-45F1-BD44-653077FCB2DD@durin42.com>
Download mbox | patch
Permalink /patch/16912/
State Not Applicable
Headers show

Comments

Augie Fackler - Oct. 8, 2016, 10:01 a.m.
> On Oct 8, 2016, at 11:53, Augie Fackler <raf@durin42.com> wrote:
> 
> Queued this, thanks.
> 
>> On Oct 8, 2016, at 10:24, Pulkit Goyal <7895pulkit@gmail.com> wrote:
>> 
>> # HG changeset patch
>> # User Pulkit Goyal <7895pulkit@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__

Hm. Can you look at this?


ERROR: test-hgwebdir-paths.py output changed


>> 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
>
Yuya Nishihara - Oct. 8, 2016, 10:12 a.m.
On Sat, 8 Oct 2016 12:01:00 +0200, Augie Fackler wrote:
> 
> > On Oct 8, 2016, at 11:53, Augie Fackler <raf@durin42.com> wrote:
> > 
> > Queued this, thanks.
> > 
> >> On Oct 8, 2016, at 10:24, Pulkit Goyal <7895pulkit@gmail.com> wrote:
> >> 
> >> # HG changeset patch
> >> # User Pulkit Goyal <7895pulkit@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__
> 
> Hm. Can you look at this?
> 
> --- /home/augie/hg/tests/test-hgwebdir-paths.py.out
> +++ /home/augie/hg/tests/test-hgwebdir-paths.py.err
> @@ -0,0 +1,20 @@
> +Traceback (most recent call last):
> +  File "/home/augie/hg/tests/test-hgwebdir-paths.py", line 4, in <module>
> +    from mercurial import (
> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/hg.py", line 19, in <module>
> +    from . import (
> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/bundlerepo.py", line 23, in <module>
> +    from . import (
> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/changelog.py", line 19, in <module>
> +    from . import (
> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/revlog.py", line 31, in <module>
> +    from . import (
> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/templatefilters.py", line 15, in <module>
> +    from . import (
> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/templatekw.py", line 11, in <module>
> +    from . import (
> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/patch.py", line 28, in <module>
> +    from . import (
> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/mail.py", line 26, in <module>
> +    _oldheaderinit = email.header.Header.__init__
> +AttributeError: 'module' object has no attribute 'header'
> 
> ERROR: test-hgwebdir-paths.py output changed

Perhaps we'll need "import email.header".
Pulkit Goyal - Oct. 8, 2016, 10:17 a.m.
On Sat, Oct 8, 2016 at 12:12 PM, Yuya Nishihara <yuya@tcha.org> wrote:
> On Sat, 8 Oct 2016 12:01:00 +0200, Augie Fackler wrote:
>>
>> > On Oct 8, 2016, at 11:53, Augie Fackler <raf@durin42.com> wrote:
>> >
>> > Queued this, thanks.
>> >
>> >> On Oct 8, 2016, at 10:24, Pulkit Goyal <7895pulkit@gmail.com> wrote:
>> >>
>> >> # HG changeset patch
>> >> # User Pulkit Goyal <7895pulkit@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__
>>
>> Hm. Can you look at this?

Yeah same as mentioned by Yuya, need to import email.header.

>>> import email
>>> email.header
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'header'

>>> email.header.Header
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'header'

>>> import email.header
>>> email.header.Header
<class email.header.Header at 0x7f771e4a7530>

>>> email.header
<module 'email.header' from '/usr/lib/python2.7/email/header.py'>

Sending a fixed patch.


>>
>> --- /home/augie/hg/tests/test-hgwebdir-paths.py.out
>> +++ /home/augie/hg/tests/test-hgwebdir-paths.py.err
>> @@ -0,0 +1,20 @@
>> +Traceback (most recent call last):
>> +  File "/home/augie/hg/tests/test-hgwebdir-paths.py", line 4, in <module>
>> +    from mercurial import (
>> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/hg.py", line 19, in <module>
>> +    from . import (
>> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/bundlerepo.py", line 23, in <module>
>> +    from . import (
>> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/changelog.py", line 19, in <module>
>> +    from . import (
>> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/revlog.py", line 31, in <module>
>> +    from . import (
>> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/templatefilters.py", line 15, in <module>
>> +    from . import (
>> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/templatekw.py", line 11, in <module>
>> +    from . import (
>> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/patch.py", line 28, in <module>
>> +    from . import (
>> +  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/mail.py", line 26, in <module>
>> +    _oldheaderinit = email.header.Header.__init__
>> +AttributeError: 'module' object has no attribute 'header'
>>
>> ERROR: test-hgwebdir-paths.py output changed
>
> Perhaps we'll need "import email.header".

Patch

--- /home/augie/hg/tests/test-hgwebdir-paths.py.out
+++ /home/augie/hg/tests/test-hgwebdir-paths.py.err
@@ -0,0 +1,20 @@ 
+Traceback (most recent call last):
+  File "/home/augie/hg/tests/test-hgwebdir-paths.py", line 4, in <module>
+    from mercurial import (
+  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/hg.py", line 19, in <module>
+    from . import (
+  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/bundlerepo.py", line 23, in <module>
+    from . import (
+  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/changelog.py", line 19, in <module>
+    from . import (
+  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/revlog.py", line 31, in <module>
+    from . import (
+  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/templatefilters.py", line 15, in <module>
+    from . import (
+  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/templatekw.py", line 11, in <module>
+    from . import (
+  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/patch.py", line 28, in <module>
+    from . import (
+  File "/tmp/hgtests.z8vTiR/install/lib/python/mercurial/mail.py", line 26, in <module>
+    _oldheaderinit = email.header.Header.__init__
+AttributeError: 'module' object has no attribute 'header'