[PATCH] mail: handle renamed email.Header

Pulkit Goyal 7895pulkit at gmail.com
Sat Oct 8 04:26:14 EDT 2016


Don't take this one, I send an updated version with test output
updated based on current tip of hg-committed.

On Fri, Oct 7, 2016 at 5:30 PM, 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 96f956b15caca4b754bbdee542173d9acef24561
> # Parent  afce80b816e2baf6ed2b828feee00115f71936b6
> 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 afce80b816e2 -r 96f956b15cac mercurial/mail.py
> --- a/mercurial/mail.py Fri Oct 07 15:29:57 2016 +0200
> +++ 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))


More information about the Mercurial-devel mailing list