Patchwork [01,of,10,STABLE] py3: decode payload of notify email

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 24, 2019, 3:30 p.m.
Message ID <4e91ce8060e960bd8f96.1571931032@steppe.local>
Download mbox | patch
Permalink /patch/42568/
State Accepted
Headers show

Comments

Denis Laxalde - Oct. 24, 2019, 3:30 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1571927683 -7200
#      Thu Oct 24 16:34:43 2019 +0200
# Branch stable
# Node ID 4e91ce8060e960bd8f9656a1f9b00fdb82199b3c
# Parent  4565a0afc2891f0bbba8ea9d9df21267d18cf832
py3: decode payload of notify email

This fixes one UnicodeEncodeError in test-notify.t:422 when testing the
notify hook with non-ascii content (there are more later).
Yuya Nishihara - Oct. 25, 2019, 12:23 p.m.
On Thu, 24 Oct 2019 17:30:32 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1571927683 -7200
> #      Thu Oct 24 16:34:43 2019 +0200
> # Branch stable
> # Node ID 4e91ce8060e960bd8f9656a1f9b00fdb82199b3c
> # Parent  4565a0afc2891f0bbba8ea9d9df21267d18cf832
> py3: decode payload of notify email
> 
> This fixes one UnicodeEncodeError in test-notify.t:422 when testing the
> notify hook with non-ascii content (there are more later).
> 
> diff --git a/hgext/notify.py b/hgext/notify.py
> --- a/hgext/notify.py
> +++ b/hgext/notify.py
> @@ -401,7 +401,7 @@ class notifier(object):
>              # create fresh mime message from scratch
>              # (multipart templates must take care of this themselves)
>              headers = msg.items()
> -            payload = msg.get_payload()
> +            payload = msg.get_payload(decode=True)

I'm not pretty sure if this is safe on Python 2.
Gregory Szorc - Oct. 26, 2019, 6:20 a.m.
On Fri, Oct 25, 2019 at 5:42 AM Yuya Nishihara <yuya@tcha.org> wrote:

> On Thu, 24 Oct 2019 17:30:32 +0200, Denis Laxalde wrote:
> > # HG changeset patch
> > # User Denis Laxalde <denis.laxalde@logilab.fr>
> > # Date 1571927683 -7200
> > #      Thu Oct 24 16:34:43 2019 +0200
> > # Branch stable
> > # Node ID 4e91ce8060e960bd8f9656a1f9b00fdb82199b3c
> > # Parent  4565a0afc2891f0bbba8ea9d9df21267d18cf832
> > py3: decode payload of notify email
> >
> > This fixes one UnicodeEncodeError in test-notify.t:422 when testing the
> > notify hook with non-ascii content (there are more later).
> >
> > diff --git a/hgext/notify.py b/hgext/notify.py
> > --- a/hgext/notify.py
> > +++ b/hgext/notify.py
> > @@ -401,7 +401,7 @@ class notifier(object):
> >              # create fresh mime message from scratch
> >              # (multipart templates must take care of this themselves)
> >              headers = msg.items()
> > -            payload = msg.get_payload()
> > +            payload = msg.get_payload(decode=True)
>
> I'm not pretty sure if this is safe on Python 2.
>

test-notify.t and test-keyword.t seemed to have regressed on Python 3.7
with this series. Compare
https://ci.hg.gregoryszorc.com/job-info/hg-committed-a2ff3aff81d244685cf2f25a1ee92f379d1d115c-debian10-cpython-3.7-0#failed-tests
with
https://ci.hg.gregoryszorc.com/job-info/hg-committed-416041f97cc333b9a1bf04d10b5502ac78a3f33d-debian10-cpython-3.7-0#failed-tests.
I'm not sure if that is due to an incomplete series landing or what.
Denis Laxalde - Oct. 26, 2019, 7:59 a.m.
Gregory Szorc a écrit :
> test-notify.t and test-keyword.t seemed to have regressed on Python 3.7
> with this series. Compare
> https://ci.hg.gregoryszorc.com/job-info/hg-committed-a2ff3aff81d244685cf2f25a1ee92f379d1d115c-debian10-cpython-3.7-0#failed-tests
> with
> https://ci.hg.gregoryszorc.com/job-info/hg-committed-416041f97cc333b9a1bf04d10b5502ac78a3f33d-debian10-cpython-3.7-0#failed-tests.
> I'm not sure if that is due to an incomplete series landing or what.

Some failures were due to incomplete landing. But now everything
has landed:

  https://ci.hg.gregoryszorc.com/job-info/hg-committed-8fda98a6842709c26b61747c7420b28cd874755e-debian10-cpython-3.7-0

There are still issues with the "Message-Id:" header in both
test-notify.t and test-keyword.t. I missed that because this only occurs
with a long hostname, that makes the header value exceed 75 characters.
I'll look into this.

Patch

diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -401,7 +401,7 @@  class notifier(object):
             # create fresh mime message from scratch
             # (multipart templates must take care of this themselves)
             headers = msg.items()
-            payload = msg.get_payload()
+            payload = msg.get_payload(decode=True)
             # for notification prefer readability over data precision
             msg = mail.mimeencode(self.ui, payload, self.charsets, self.test)
             # reinstate custom headers