Patchwork [02,of,10,STABLE] py3: use as_bytes() method of EmailMessage

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 24, 2019, 3:30 p.m.
Message ID <07e05c72d451036707ac.1571931033@steppe.local>
Download mbox | patch
Permalink /patch/42569/
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 1570708110 -7200
#      Thu Oct 10 13:48:30 2019 +0200
# Branch stable
# Node ID 07e05c72d451036707ac8c7f9a283617ac9534f8
# Parent  4e91ce8060e960bd8f9656a1f9b00fdb82199b3c
py3: use as_bytes() method of EmailMessage

In Python 3, as_bytes() corresponds to as_string() in Python 2.
Yuya Nishihara - Oct. 25, 2019, 12:21 p.m.
On Thu, 24 Oct 2019 17:30:33 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1570708110 -7200
> #      Thu Oct 10 13:48:30 2019 +0200
> # Branch stable
> # Node ID 07e05c72d451036707ac8c7f9a283617ac9534f8
> # Parent  4e91ce8060e960bd8f9656a1f9b00fdb82199b3c
> py3: use as_bytes() method of EmailMessage

Queued 2, 3, 5, 6, 7, 8, 9, thanks.

Patch

diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -440,7 +440,7 @@  class notifier(object):
             msg[r'Message-Id'] = messageid(ctx, self.domain, self.messageidseed)
         msg[r'To'] = encoding.strfromlocal(b', '.join(sorted(subs)))
 
-        msgtext = encoding.strtolocal(msg.as_string())
+        msgtext = msg.as_bytes() if pycompat.ispy3 else msg.as_string()
         if self.test:
             self.ui.write(msgtext)
             if not msgtext.endswith(b'\n'):