[PATCH] mail: handle renamed email.Header

Pulkit Goyal 7895pulkit at gmail.com
Sat Oct 8 06:17:23 EDT 2016


On Sat, Oct 8, 2016 at 12:12 PM, Yuya Nishihara <yuya at 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 at durin42.com> wrote:
>> >
>> > Queued this, thanks.
>> >
>> >> On Oct 8, 2016, at 10:24, Pulkit Goyal <7895pulkit at gmail.com> wrote:
>> >>
>> >> # HG changeset patch
>> >> # User Pulkit Goyal <7895pulkit at 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".


More information about the Mercurial-devel mailing list