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

Denis Laxalde denis at laxalde.org
Thu Oct 24 11:30:33 EDT 2019


# HG changeset patch
# User Denis Laxalde <denis.laxalde at 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.

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'):


More information about the Mercurial-devel mailing list