py3: use as_bytes() method of EmailMessage stable
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 10 Oct 2019 13:48:30 +0200
branchstable
changeset 43322 7d912413a3ae
parent 43321 a2ff3aff81d2
child 43323 84c15836a2d7
py3: use as_bytes() method of EmailMessage In Python 3, as_bytes() corresponds to as_string() in Python 2.
hgext/notify.py
--- a/hgext/notify.py	Wed Oct 23 23:00:58 2019 +0100
+++ b/hgext/notify.py	Thu Oct 10 13:48:30 2019 +0200
@@ -440,7 +440,7 @@
             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'):